You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 174.91 ms for <name>.csproj.
<user>\.nuget\packages\nerdbank.gitversioning\3.0.25\build\Nerdbank.GitVersioning.targets(63,5): error MSB4062: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task could not be loaded from the assembly <user>\.nuget\packages\nerdbank.gitversioning\3.0.25\build\MSBuildCore/Nerdbank.GitVersioning.Tasks.dll. Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [<name>.csproj]
Microsoft.Torch.Common -> C:\src\microsoft\torch-int\torch.temp\Light45\src\lib\Microsoft.Torch.Common\bin\Release\net45\Microsoft.Torch.Common.dll
Build FAILED.
The net45 target is built, but not the netstandard2.0.
Build also fails with a framework command line parameter such as:
dotnet msbuild <name>.csproj -p:Configuration=Release also fails as follows:
Microsoft (R) Build Engine version 16.2.32702+c4012a063 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
<user>\.nuget\packages\nerdbank.gitversioning\3.0.25\build\Nerdbank.GitVersioning.targets(63,5): error MSB4062: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task could not be loaded from the assembly <user>\.nuget\packages\nerdbank.gitversioning\3.0.25\build\MSBuildCore/Nerdbank.GitVersioning.Tasks.dll. Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [<name>.csproj]
<name> -> <name>\bin\Release\net45\<name>.dll
The text was updated successfully, but these errors were encountered:
This is a failing in MSBuild Core I guess, which isn't properly handling multi-load or unload of msbuild task assemblies.
From my experience with this, I'm pretty sure it actually has nothing to do with the fact that you're targeting multiple frameworks in your own project. Rather, it's because you've previously built some project that consumes a different version of NB.GV. That build was in a process that stuck around and served your subsequent build request. You can clear out these problematic processes by running dotnet build-server shutdown then building again. This will guarantee you have fresh msbuild processes and you should get just one version of NB.GV loaded and it will work.
The other possibility is that you have a single solution/repo which consume multiple versions of NB.GV. That makes it double-hard for msbuild to get the assembly loading right, so you should definitely make sure each repo references exactly one version of NB.GV. Then your dotnet build-server shutdown command gets you to a clean slate and your repo can build with its one version.
Thank you, @AArnott. dotnet build-server shutdown worked locally, so that's great. What is weird is that I picked up this problem when I pushed this to an AzDO PR. VS builds at the time were fine. However, the latest push worked fine.
Create a library project with:
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
that references
Nerdbank.GitVersioning
with2.3.181
<=Version
<=3.0.25
(may occur with other versions, but I only tested these versions)Running
dotnet build <name>.csproj -t:Build -p:Configuration=Release
fails with:The
net45
target is built, but not thenetstandard2.0
.Build also fails with a framework command line parameter such as:
dotnet build <name>.csproj -t:Build -p:Configuration=Release --framework netstandard2.0
dotnet build <name>.csproj -t:Build -p:Configuration=Release --framework net45
Build is successful if
TargetFrameworks
has only one of the TFMs:<TargetFrameworks>net45</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
dotnet msbuild <name>.csproj -p:Configuration=Release
also fails as follows:The text was updated successfully, but these errors were encountered: