question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building a .NET Core 3.1 project results in MSB4062

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rainersigwaldcommented, Jan 23, 2020

@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 https://github.com/microsoft/msbuild/pull/4916.

0reactions
tmatcommented, Jan 23, 2020

@rainersigwald That would explain. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >
Announcing .NET Core 3.1
Announcing .NET Core 3.1. We're excited to announce the release of .NET Core 3.1. It's really just a small set of fixes and...
Read more >
Problems when building Uno Platform project from ...
1 Answer 1 ·.NET Core 2 was just something I was trying out to see if that worked. · In this case, you...
Read more >
Episode 1: Creating a new .NET Core 3.1 Project - YouTube
Development on Request Metrics begins! Before we can write any fun, (hopefully) money making code, we need to get some unexciting ground ...
Read more >
c# - .NET Core 2 build is not working in .NET Core 3.1
I have a build server that has .NET Core 2.2.110 installed in it. For my new application, I need .NET Core 3.1. So...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found