Build is failing with .net sdk

Morde, Yogeshwari 0 Reputation points
2024-02-06T14:46:19.0933333+00:00

Hi, We are trying to build our CSPROJ using dotnet sdk 6.0.407 version also tried with 7.0.306 version but getting below error. This is running from jenkins and dotnet is installed on Windows Server. Please guide as we are stuck here. This is the output.

set MSBuildSDKsPath=C:\Program Files\dotnet\sdk\7.0.306\Sdks set MSBuildEnableWorkloadResolver = false "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" WPF_Client.csproj /t:Restore;Build /p:TargetFramework=net6.0-windows10.0.20348.0 /p:Platform="Any CPU" > C:\Program Files\Git\cmd\git checkout # timeout=10MSBuild version 17.4.1+9a89d02ff for .NET FrameworkBuild started 2/5/2024 10:13:56 AM.Project "D:\Workdir\jenkins\workspace\WPF_Client.csproj" on node 1 (Restore;Build target(s)).C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.props(142,3): error MSB4024: The imported project file "C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props" could not be loaded. Root element is missing. [D:\Workdir\jenkins\workspace\WPF_Client.csproj]Done Building Project "D:\Workdir\jenkins\workspace\WPF_Client.csproj" (Restore;Build target(s)) -- FAILED.Build FAILED.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,648 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 51,346 Reputation points
    2024-02-06T17:30:34.2666667+00:00

    It looks like either your WPF_Client.csproj file or the Microsoft.NET.Sdk.ImportWorkloads.props file is bad. The error seems to indicate that the XML file is missing the root <Project> element. But without seeing the project file I'm just guessing here.

    Does this build correctly in Visual Studio? If it does then that would eliminate the project file so the followup would be to confirm that the appropriate toolsets are installed on your build server.

    0 comments No comments