Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building a .NET Core 3.1 project results in MSB4062 #524

Closed
mmisztal1980 opened this issue Dec 4, 2019 · 8 comments
Closed

Building a .NET Core 3.1 project results in MSB4062 #524

mmisztal1980 opened this issue Dec 4, 2019 · 8 comments
Labels

Comments

@mmisztal1980
Copy link

Hi,

After upgrading my solution to .NET Core 3.1, I've started to notice that my builds are failing due to sourcelink? Can anyone elaborate on what the issue is, and can I work around this in any way?

Core.Serialization.csproj

<Project Sdk="Microsoft.NET.Sdk">

   <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <OutputType>library</OutputType>
    <IsPackable>true</IsPackable>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
  </PropertyGroup>  

  <ItemGroup>  
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
    <PackageReference Include="protobuf-net" Version="2.4.0" />
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\..\core-pkg\src\Core\Core.csproj" />
  </ItemGroup>
</Project>

Build output

error MSB4062: The "Microsoft.Build.Tasks.Git.LocateRepository"
task could not be loaded from the assembly 
/root/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta2-19367-01/build/../tools/netcoreapp2.0/Microsoft.Build.Tasks.Git.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
@stuart-blackler-cko
Copy link

I've also found that this happens with 1.0.0-beta2-19554-01 also

@tmat
Copy link
Member

tmat commented Dec 21, 2019

@mmisztal1980 @WeihanLi Would you mind sharing a binary log (when using 1.0.0 Source Link version)? You can produce one by calling dotnet build /bl. The log includes details of your environment so you might not want to share it publicly. You can send it to [email protected].

@WeihanLi
Copy link

Hi @tmat , sorry for my late reply, just tried but could not reproduce the exception with 1.0.0, sorry for your time

@tillig
Copy link

tillig commented Jan 22, 2020

@tmat I just hit this with a solution that has all netcoreapp3.1 libraries and one netstandard2.0 library. They all reference Microsoft.SourceLink.AzureRepos.Git 1.0.0. I will send you a log shortly via email.

@tmat
Copy link
Member

tmat commented Jan 23, 2020

It seems that the build process has multiple versions of Microsoft.Build.Tasks.Git.dll loaded for some reason (or rather it has one and is attempting to load another). I'm not sure why this would be a problem. @rainersigwald Shouldn't this problem have been fixed on .NET Core?

As a workaround I'd try to

  1. update all projects to 1.0.0 version of Source Link
  2. kill all dotnet.exe processes before the build

@tmat
Copy link
Member

tmat commented Jan 23, 2020

Actually, it seems that one project loads
microsoft.build.tasks.git/1.0.0/build/../tools/netcoreapp2.0/Microsoft.Build.Tasks.Git.dll successfully, but other projects in the solution do not. Very odd. @rainersigwald msbuild bug?

@rainersigwald
Copy link
Member

@tillig had you previously built a solution that used a different version of Microsoft.Build.Tasks.Git? This part

Actually, it seems that one project loads
microsoft.build.tasks.git/1.0.0/build/../tools/netcoreapp2.0/Microsoft.Build.Tasks.Git.dll successfully, but other projects in the solution do not.

could be explained by MSBuild node reuse: newly-created nodes can load the 1.0.0 version fine; older ones had a different version loaded and failed.

Prior to .NET Core SDK 3.1.200 (not yet released), MSBuild could only load one version of an assembly in the lifetime of the process. By default, worker nodes live past the build invocation that created them. This is a bad combination! But should be fixed in the future by dotnet/msbuild#4916.

@tmat tmat added the external label Jan 23, 2020
@tmat
Copy link
Member

tmat commented Jan 23, 2020

@rainersigwald That would explain. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants