Tanuj
Tanuj

Reputation: 61

Jenkins not compiling with .NET Core 3.1 version using MSBuild

I have an environment where Jenkins has installed locally and there are 4 visual studio projects inside the solution having all .NET Core 3.1 version. I installed the build tools for Visual Studio 2019 and MSBuild plugin for Jenkins. I do not have full IDE installed for Visual Studio 2019.

I also ran the "dotnet --info" where the jenkins is installed and here is the output: enter image description here

After doing this step also I am not able to compile the project. Please see the error below: Error seen while building Jenkins

I also tried setting the environment variables but it is not helping using the instruction in this page (https://github.com/dotnet/msbuild/issues/2532). Can someone please help and point me what I am doing wrong.

EDIT

I restarted the server and now I am getting this error: Error after restart of the server

Upvotes: 1

Views: 2193

Answers (2)

I faced the same issue:

"The runtime pack for Microsoft.NETCore.App.Runtime.win-x64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'win-x64'

When building a .NET Core 3.1 application (sln with multiple csproj files) using MSBuild in a Windows self-hosted runner in GitHub actions (I don't think the CI tooling has nothing to do with the problem as I could reproduce it on my own Windows machine).

The way I managed to solve it was by adding the following RuntimeIdentifiers section to the csproj files:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
  </PropertyGroup>

Also, before building the project with MSBuild (I had to use MSBuild because I was building an MSI and couldn't use dotnet to build) I would do a dotnet restore with the -r switch and win-x64 as the value:

dotnet restore -r win-x64

Upvotes: 0

Tanuj
Tanuj

Reputation: 61

I am just posting the solution what worked for me during that time. This was long time back and hence pasting images that I kept in my notes for future reference.

enter image description here

enter image description here

enter image description here

enter image description here

Upvotes: 1

Related Questions