Share via

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.

Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.


1 answer

Sort by: Most helpful
  1. Michael Taylor 61,221 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.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.