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
{{ message }}
Repository navigation
Support for dotnet (prev. DNX) / .NET Core projects #647
In DNX / .NET Core projects the version is set via the project.json file described here in the Metadata section. AssemblyInfo.cs on the other hand is gone. I'd like to use GitVersion with such projects.
Out of the box support for the project.json file seems like a natural extension for GitVersion.
There is nothing to stop you using GitVersion today though, you could execute the GitVersion.exe on your repository, establish what the asserted Semantic Version is, and then manually update the project.json file using perhaps a regular expression.
Should it really be the task of GitVersion to update versions in all possible project types? If this is in the scope of GitVersion I would suggest to introduce some kind of interface like it is already done for the build server which easily can be extended to other project types (we use GitVersion for example for SharePoint Add-ins which also have their own XML file which contains the version number)
You would potentially need a composite of these updaters to run. For example if you had a solution containing a library (assembly info), a vsix package (xml), and an asp.net 5 website (project.json) you would want possibly all 3 to be updated.. or maybe just one. This would complicate things a bit for gitversion.
There must be existing tools out there for updating xml / json files..
On a side note, project.json is really not just ASP.NET, but rather sort of the upcoming standard project type for .NET. With the framework multi-targeting it's a safe bet that sooner or later all NuGet projects will adapt to that one.
On a side note, project.json is really not just ASP.NET, but rather sort of the upcoming standard project type for .NET.
This was really my reasoning for including it within GitVersion. We have already included Assemblnfo.cs/.vb, which is the default .Net way of versioning a project. If project.json is becoming the new defacto, then IMO, this should also be included OOTB.
If we can setup something in the YAML file to make it more scalable, i.e. look for files matching this pattern, and replace entries with this pattern, with this GitVersion variable, then I would be all for that approach as well.
You might want to know that DNX uses a versioning feature where a 1.0.0-* project version in project.json is rendered as 1.0.0 normally, but as 1.0.0-whatever when DNX_BUILD_VERSION=whatever is set in the environment. There also seems to exist DNX_ASSEMBLY_FILE_VERSION.
Also, commands defined in the project.json are directly executed by the DNX and this is generally done with the test command at the moment (see here):
Here xunit.runner.dnx (→ GitHub) is installed via NuGet. The canonical behavior seems to be to look for project.json files that contain this command and then execute dnx test in that directory as part of the build process (see below).
I could imagine hooking GitVersion in there with a version command.
"Default" build system
It's not necessarily directly related and I understand that not every scenario in the world has to be addressed by GitVersion, but this might be something you want to have an eye on.
The ASP.NET 5 team apparently uses KoreBuild and Sake as their self-contained cross-platform build system (which interestingly also has TeamCity integration) and it's getting some love in the community, e.g. here and here. There's a minimal example here, however there seems to be nada documentation available, like everywhere in the ASP.NET 5 world right now.
A very simple makefile.shade would look like this:
var VERSION='0.1'
var FULL_VERSION='0.1'
var AUTHORS='Contributors'
use-standard-lifecycle
k-standard-goals
From _use-standard-goals.shade it would seem that VERSION and FULL_VERSION are used to update AssemblyInfo.cs files if found, FULL_VERSION is in addition passed to nuget pack as the package version. The _k-standard-goals.shade in the Universe repo linked above skips that part and does not seem to patch project.json, however. There are git commands in the standard shadefiles, so this might be an interesting approach to integrate GitVersion in the build process as a use-gitversion step.
Unfortunately not. I tried to use prebuild to alter the project.json file with the semver version computed from the repository. The issue is that project.json is NOT read again after prebuild commands have been executed (same for prepack).
(Note: the generation of the AssemblyInfo.cs is okay: the Version, FileVersion and InformationalVersion are correctly compiled).
@RichiCoder1 I think the biggest challenge is figuring out how to integrate calling GitVersion in the dotnet build pipeline. @olivier-spinelli's experiments weren't positive but a lot has changed since then and maybe the behavior is difference with the dotnet CLI over dnx?
Would you be able to submit pull requests to each of these projects to add netstandard support if you got it working. It would be better to not fork the community if possible.
I guess the next thing to watch is libgit2/libgit2sharp#1318, once that is merged and drops we can update GitTools.Core and GitVersion.Core to support netstandard. Then we can release a gitversion for dotnet cli
@JakeGinnivan agree, unlisted LibGit2Sharp.NativeBinaries-dotnet as that's now fixed upstream.
I opened pull requests with all projects, and only forked because libgit2/libgit2sharp#1318 is moving at a glacial pace. The changes are all there, but nobody seems to be able to merge it.
Thought about using the existing mono build, but that doesn't work as a dotnet cli tool, which is running not as an native executable but a .net assembly that's executed by coreclr.
Also it's quite a bit cleaner and slicker to use coreclr directly.
Thought about using the existing mono build, but that doesn't work as a dotnet cli tool, which is running not as an native executable but a .net assembly that's executed by coreclr.
Also it's quite a bit cleaner and slicker to use coreclr directly.
I was thinking wrapping, so create a native .net cli app which simply shells out to gitversion?
The version of @ah- does not update the "local dependencies" in a multiproject. It seems, we need a combination of what SimpleGitVersion does and the dotnet-gitversion poc.
Activity
gep13 commentedon Sep 17, 2015
Out of the box support for the project.json file seems like a natural extension for GitVersion.
There is nothing to stop you using GitVersion today though, you could execute the GitVersion.exe on your repository, establish what the asserted Semantic Version is, and then manually update the project.json file using perhaps a regular expression.
pascalberger commentedon Sep 17, 2015
Should it really be the task of GitVersion to update versions in all possible project types? If this is in the scope of GitVersion I would suggest to introduce some kind of interface like it is already done for the build server which easily can be extended to other project types (we use GitVersion for example for SharePoint Add-ins which also have their own XML file which contains the version number)
dazinator commentedon Sep 17, 2015
You would potentially need a composite of these updaters to run. For example if you had a solution containing a library (assembly info), a vsix package (xml), and an asp.net 5 website (project.json) you would want possibly all 3 to be updated.. or maybe just one. This would complicate things a bit for gitversion.
There must be existing tools out there for updating xml / json files..
sunsided commentedon Sep 17, 2015
On a side note,
project.jsonis really not just ASP.NET, but rather sort of the upcoming standard project type for .NET. With the framework multi-targeting it's a safe bet that sooner or later all NuGet projects will adapt to that one.gep13 commentedon Sep 17, 2015
This was really my reasoning for including it within GitVersion. We have already included Assemblnfo.cs/.vb, which is the default .Net way of versioning a project. If project.json is becoming the new defacto, then IMO, this should also be included OOTB.
If we can setup something in the YAML file to make it more scalable, i.e. look for files matching this pattern, and replace entries with this pattern, with this GitVersion variable, then I would be all for that approach as well.
sunsided commentedon Sep 20, 2015
You might want to know that DNX uses a versioning feature where a
1.0.0-*project version inproject.jsonis rendered as1.0.0normally, but as1.0.0-whateverwhenDNX_BUILD_VERSION=whateveris set in the environment. There also seems to existDNX_ASSEMBLY_FILE_VERSION.Also, commands defined in the
project.jsonare directly executed by the DNX and this is generally done with thetestcommand at the moment (see here):Here
xunit.runner.dnx(→ GitHub) is installed via NuGet. The canonical behavior seems to be to look forproject.jsonfiles that contain this command and then executednx testin that directory as part of the build process (see below).I could imagine hooking GitVersion in there with a
versioncommand."Default" build system
It's not necessarily directly related and I understand that not every scenario in the world has to be addressed by GitVersion, but this might be something you want to have an eye on.
The ASP.NET 5 team apparently uses KoreBuild and Sake as their self-contained cross-platform build system (which interestingly also has TeamCity integration) and it's getting some love in the community, e.g. here and here. There's a minimal example here, however there seems to be nada documentation available, like everywhere in the ASP.NET 5 world right now.
A very simple
makefile.shadewould look like this:From _use-standard-goals.shade it would seem that
VERSIONandFULL_VERSIONare used to updateAssemblyInfo.csfiles if found,FULL_VERSIONis in addition passed tonuget packas the package version. The_k-standard-goals.shadein the Universe repo linked above skips that part and does not seem to patchproject.json, however. There aregitcommands in the standard shadefiles, so this might be an interesting approach to integrate GitVersion in the build process as ause-gitversionstep.clairernovotny commentedon Oct 20, 2015
There are now support for pre/post build script commands in beta 8 of the DNX tooling. This may be possible now....
olivier-spinelli commentedon Nov 2, 2015
Unfortunately not. I tried to use prebuild to alter the project.json file with the semver version computed from the repository. The issue is that project.json is NOT read again after prebuild commands have been executed (same for prepack).
(Note: the generation of the AssemblyInfo.cs is okay: the Version, FileVersion and InformationalVersion are correctly compiled).
sunsided commentedon Nov 2, 2015
Crap, sorry, accidentally hit the close button.
RichiCoder1 commentedon Mar 10, 2016
Any update? I might be interested in taking this up.
clairernovotny commentedon Mar 10, 2016
@RichiCoder1 I think the biggest challenge is figuring out how to integrate calling GitVersion in the dotnet build pipeline. @olivier-spinelli's experiments weren't positive but a lot has changed since then and maybe the behavior is difference with the dotnet CLI over dnx?
23 remaining items
ah- commentedon Jul 28, 2016
@droyad i built a simple proof of concept a bit ago: https://github.com/ah-/dotnet-gitversion
JakeGinnivan commentedon Aug 14, 2016
@ah- where is the source for https://www.nuget.org/packages/GitTools.Core-dotnet/ and https://www.nuget.org/packages/GitVersionCore-dotnet/
https://www.nuget.org/packages/LibGit2Sharp.NativeBinaries-dotnet
Would you be able to submit pull requests to each of these projects to add netstandard support if you got it working. It would be better to not fork the community if possible.
JakeGinnivan commentedon Aug 14, 2016
Ah, I just found libgit2/libgit2sharp.nativebinaries#39
JakeGinnivan commentedon Aug 14, 2016
@ah- I think you can unlist https://www.nuget.org/packages/LibGit2Sharp.NativeBinaries-dotnet now as that has the change you suggested and the native dlls in the runtimes folder?
I guess the next thing to watch is libgit2/libgit2sharp#1318, once that is merged and drops we can update GitTools.Core and GitVersion.Core to support netstandard. Then we can release a gitversion for dotnet cli
JakeGinnivan commentedon Aug 14, 2016
Is there anyway we could just wrap the already compiled exe, because it is cross platform via mono.
ah- commentedon Aug 14, 2016
@JakeGinnivan agree, unlisted LibGit2Sharp.NativeBinaries-dotnet as that's now fixed upstream.
I opened pull requests with all projects, and only forked because libgit2/libgit2sharp#1318 is moving at a glacial pace. The changes are all there, but nobody seems to be able to merge it.
Thought about using the existing mono build, but that doesn't work as a dotnet cli tool, which is running not as an native executable but a .net assembly that's executed by coreclr.
Also it's quite a bit cleaner and slicker to use coreclr directly.
JakeGinnivan commentedon Aug 15, 2016
I was thinking wrapping, so create a native .net cli app which simply shells out to gitversion?
dazinator commentedon Oct 23, 2016
Anyone made any headway with asp net core support (proejct.json) or are we going to wait it out until project.json ihas gone away?
sunsided commentedon Oct 23, 2016
@dazinator Well @ah- made https://github.com/ah-/dotnet-gitversion which is awesome. With msbuild tooling around the corner I wouldn't rely too much on it now though. They have a history of breaking stuff that used to work fine in beta ...
bravecobra commentedon Nov 10, 2016
The version of @ah- does not update the "local dependencies" in a multiproject. It seems, we need a combination of what SimpleGitVersion does and the dotnet-gitversion poc.
droyad commentedon Nov 10, 2016
@bravecobra How do you mean? I've been using the following syntax to reference other projects:
bravecobra commentedon Nov 10, 2016
@droyad I didn't know you could to that. Tnx!
GitVersionTask is incompatible with dotnet GitTools/GitVersion#647
asbjornu commentedon Mar 1, 2019
.NET Core support (.NET Standard 1.3) was added in #1269, .NET Core 2.1 (.NET Standard 2.0) support in #1422.