GitVersion: Building using dotnet build fails for .NET Standard library project
I’m using the latest pre-release of GitVersionTask (4.0.0-beta0011) on a .NET standard library project and it seems to work from Visual Studio 2017 but not from the command line using dotnet build. I’m targeting netstandard1.2.
I wasn’t sure whether this would work at all. I started off looking around for an implementation that installs a GitVersion package as a DotnetCliToolReference in an SDK csproj file. With nothing conclusive from that or from other .NET Core related issues (ex. https://github.com/GitTools/GitVersion/issues/647) I figured I should just try adding the package reference and see what it does. I was happy at first to see it was working when building the solution from Visual Studio but building using dotnet build gives me the following error.
Microsoft ® Build Engine version 15.1.545.13942 Copyright © Microsoft Corporation. All rights reserved.
C:\Users\me.nuget\packages\gitversiontask\4.0.0-beta0011\build\GitVersionTask.targets(45,5): error MSB4062: The “GitVersionTask.WriteVersionInfoToBuildLog” task could not be loaded from the assembly C:\Users\me.nuget\packages\gitversiontask\4.0.0-beta0011\build\GitVersionTask.dll. Could not load file or assembly ‘Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL’. The system cannot find the file specified. 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. [C:\Users\me\source\myproj\src\MyProj\MyProj.csproj] C:\Program Files\dotnet\sdk\1.0.0-rc4-004771\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for ‘C:\Users\me\source\myproj\src\MyProj\MyProj.csproj’. This can indicate a missing project reference. [C:\Users\me\source\myproj\src\TestCore\TestCore.csproj]
Build FAILED.
C:\Users\me.nuget\packages\gitversiontask\4.0.0-beta0011\build\GitVersionTask.targets(45,5): error MSB4062: The “GitVersionTask.WriteVersionInfoToBuildLog” task could not be loaded from the assembly C:\Users\me.nuget\packages\gitversiontask\4.0.0-beta0011\build\GitVersionTask.dll. Could not load file or assembly ‘Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL’. The system cannot find the file specified. 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. [C:\Users\me\source\myproj\src\MyProj\MyProj.csproj] C:\Program Files\dotnet\sdk\1.0.0-rc4-004771\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Cannot find project info for ‘C:\Users\me\source\myproj\src\MyProj\MyProj.csproj’. This can indicate a missing project reference. [C:\Users\me\source\myproj\src\TestCore\TestCore.csproj] 0 Warning(s) 2 Error(s)
Time Elapsed 00:00:01.09
According to the documentation:
Support for
CoreCLRwithdotnet buildis coming soon.
Is there anywhere I can follow along with the work being done for getting GitVersionTask or some form of automated solution that works for .NET library projects?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 53 (34 by maintainers)
Commits related to this issue
- #1175 - First pass at GitVersionCore on netstadard - wip. Haven't been able to resolve some compilation errors yet due to lack of replacemnt API's on netstandard. — committed to dazinator/GitVersion by dazinator 7 years ago
- Merge pull request #1269 from dazinator/feature/netstandard #1175 - NetStandard — committed to GitTools/GitVersion by dazinator 6 years ago
Yeah, it cannot work with
dotnet build.dotnet builduses the CoreCLR and the tasks are currently compiled for the desktop framework. You have to usemsbuild.exe /t:restore,mbbuild.exe /t:build, andmsbuild.exe /t:packas the equiv of dotnet restore, dotnet build and dotnet pack.Once GitVersion has .NET Standard versions of the underlying assemblies, we can create .NET Standard build task and support it easily. I believe LibGit2Sharp now has this support as NerdBank.GitVersioning has a .NET Standard version now that uses LibGit2Sharp.
Will try that in 2 or 3 after my vacation… GitVersion on TFS/VSTS is a bit of a strange beast.
On one side we need the assemblies to have a specific version so it can version it on the other side the nuget packages and the build itself, so a mix of both NugetPackage based tasks and cli is required to get proper versioning for CI/CD.
It looks like it’s used to format version numbers in line with a customisable template. I won’t be able to look at this again for a while now, so happy for someone else to give this ago. Perhaps I should raise “Remove / Replace System.Web” as a new / separate issue?
Im planning on starting the PR for this, this week. Not sure what to do about ILRepack just yet but we shall see!
Checkout the pr named Netstandard. It has instructions. Short answer is yes you can do this now. Not yet been merged but you can try the PR nuget packages. Let me know how you get on!
Right we think we have resolved the libgit2sharp native dependency issue now. So no need to use my fork of libgit2sharp after all. Next thing I / we need to do is get the appveyor build working and publishing nuget packages similar to gittools.core. anyone can feel free to jump in and look at the appveyor build / travis builds of the netstandard PR, Just drop a note if you do so that we dont overlap.
@asbjornu I started on the port of
GitTools.Corebut could not get it building yet. Its in a feature branch - If curious see: https://github.com/GitTools/GitTools.Core/issues/40Just hit this when running
dotnet teston an xunit project, that has a project reference to the project with the gitversion task. I am not sure what the equivalent ofdotnet testis for msbuild, however managed to workaround this by:dotnet test --no-buildto execute the tests.