Nuget Broke my Build — error MSB4181: The “PackTask” task returned false but did not log an error.

I recently decided to update my dotnet core sdk tools to the latest version. I did this by installing the latest sdk and updating my global.json file. If you read the MS documentation then all will be good, that however was not my experience.

The new global.json was

{
"sdk": {
"version": "3.1.407",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}

All seemed fine until I ran a dotnet pack command — specifically dotnet pack -c Release which generated the error

C:\Program Files\dotnet\sdk\3.1.407\Sdks\NuGet.Build.Task
s.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets
(198,5): error MSB4181: The "PackTask" task returned fals
e but did not log an error.

Although this appears to be related to the fact that I prefer Paket, the solution may work for nuget users too, though I haven’t tested it.

Fortunately for me the solution was a simple one, I simply reverted global.json to the following

{
"sdk": {
"version": "3.1.302",
"rollForward": "latestPatch",
"allowPrerelease": false
}
}

which is what I have for most of my libraries. The important part here is the SDK version of 3.1.302. If I use this everything works as expected.

Luckily for me I am using an LTS, if you happen to be using .NET 5 then you may have to wait for a solution

Senior IT Officer for North Lincolnshire Council