Repository navigation
Description
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. #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 (R) Build Engine version 15.1.545.13942
Copyright (C) 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 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 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?
Activity
JakeGinnivan commentedon Mar 1, 2017
@onovotny any thoughts? :)
clairernovotny commentedon Mar 1, 2017
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.
TAGC commentedon Mar 15, 2017
Which of GitVersion's dependencies are currently blocking progress on the migration?
asbjornu commentedon Mar 16, 2017
@TAGC: Not sure. Here's a dump of GitVersion's
packagesfolder:I assume most of these need to be ported to .NET Standard before GitVersion can?
conniey commentedon Apr 14, 2017
@asbjornu Yes... or an alternative would have to be found for them.
The ones that do not exist are:
dazinator commentedon Jun 7, 2017
Just 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.el2iot2 commentedon Jun 25, 2017
Just saw on Twitter that the PR for LibGit2Sharp got merged. That brings this issue one step closer to resolution, it would seem.
el2iot2 commentedon Jun 25, 2017
Yep after a quick survey, only PepitaPackage and ApprovalTests don't have netstandard support?
dazinator commentedon Jun 27, 2017
I don't think ApprovalTests should matter as this is a build time only dependency surely - (i.e for running tests) so shouldn't be a dependency that is forced onto consumers?
dazinator commentedon Jun 27, 2017
Also just a note to say that even though calling msbuild instead of dotnet cli will provide a workaround for some scenarios, for others, like
dotnet efI can't find any equivalent msbuild commands so this remains a problem.dazinator commentedon Jun 27, 2017
I have looked at the dependencies and filtered down the relevent ones for
gitversiontaskwhich are:dazinator commentedon Jun 27, 2017
Notable we would need to add support for netcore to GitTools.Core first.
dazinator commentedon Jun 27, 2017
So the blockers seem to be:
ILRepack: https://github.com/gluck/il-repack/blob/master/ILRepack/packages.configYamlDotNet has a .NET standard version of the package that I assume we could switch too. https://www.nuget.org/packages/YamlDotNet.NetCore/
asbjornu commentedon Jun 28, 2017
@dazinator:
GitTools.Coreshould be a simple port. But I'm not quite sure what we're usingILRepackfor. @JakeGinnivan?dazinator commentedon Jun 28, 2017
@asbjornu I started on the port of
GitTools.Corebut could not get it building yet. Its in a feature branch - If curious see: GitTools/GitTools.Core#4026 remaining items
dazinator commentedon Jan 23, 2018
@tmds Nope I missed it! But I will look at that now!
thestonehead commentedon Mar 2, 2018
Is this going to be released any time soon? It would make our CI much easier.
pbalaga commentedon Apr 6, 2018
Any news on this one? I think there is still a lot of interest in it. :) What are the blockers as of now?
dazinator commentedon Apr 6, 2018
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!
pbalaga commentedon Apr 6, 2018
Sounds good! Thanks!
TsengSR commentedon Apr 6, 2018
@dazinator: That sounds good though, but can that one be used with the TFS/VSTS pipeline? The only available package for VSTS fromt he store is 3.6.5 one.
It would be cool to have the 4.x .NET Standard bits packaged within it, and allows us to change the Version via the little "version" drop-down menu? Microsoft does the same with the TFS/VSTS BuildTasks for .NET Core, where they'd set "1." versions as default and "2. (Preview)" (its out of preview by now already) could be chosen manually when needing the newer version?
I played around with the the GitVersionTask nuget packages including into your project on our VSTS build pipeline, but right now it only works on the hosted Windows Pipelines, not on the linux based ones (due to lack of mono and .NET Core/Standard support).
Or is the VSTS BuildTask Extension obsolete now with the 4.x versions and we just need to use the dotnet core build task and invoke the cli?
One bit success I had a few months ago with the Extensions and the nuget packages available form the official nuget feeds (4.0 beta12 preview iirc) was to generate the appropriately assembly versions in AssemblyInfo.cs, but only with the Extension and on Windows Hosted Build Agent.
dazinator commentedon Apr 6, 2018
The TFS package, and the GEM package aren't being built from the PR branch yet unfortunately.
To Run on Linux you might try:
Do any of those options help?
Customising the TFS package is beyond my experience, I would like to get the artifcat being built in the PR branch as a first step!
TsengSR commentedon Apr 6, 2018
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.
dazinator commentedon May 27, 2018
Any joy on this?
fleed commentedon Jun 18, 2018
@dazinator how do I get the PR nuget packages?
dazinator commentedon Jun 19, 2018
@fleed you donate £10 into my bank account and then I email you the package :-)
On a more seripus note, this is how:
it tells you about the CI nuget feed you need to add (hosted on appveyor) and the nuget package version you need to reference.
Merge pull request #1269 from dazinator/feature/netstandard
richardgavel commentedon Jan 17, 2019
Are we saying there almost needs to be a matrix of GitVersion/NET Core SDK version combinations that are known to work together?
asbjornu commentedon Jun 27, 2019
I believe that after upgrading to LibGit2Sharp 0.26 in #1713, this problem should be fixed. Can you please try the latest build of GitVersion and report back whether it fixes this problem or not? Please reopen this issue if the problem persists.