-
Notifications
You must be signed in to change notification settings - Fork 650
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
Support for dotnet (prev. DNX) / .NET Core projects #647
Comments
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, |
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 Also, commands defined in the "dependencies": {
"xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-*"
},
"commands": {
"test": "xunit.runner.dnx"
} Here I could imagine hooking GitVersion in there with a "Default" build systemIt'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
From _use-standard-goals.shade it would seem that |
There are now support for pre/post build script commands in beta 8 of the DNX tooling. This may be possible now.... |
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). |
Crap, sorry, accidentally hit the close button. |
Any update? I might be interested in taking this up. |
@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? |
You mean ssomething like https://github.com/dotnet/cli/blob/a709f772f10e4c1caeab4199ba24ebc08590f036/TestAssets/TestProjects/TestAppWithScripts/project.json#L21? There's no other way "plug in" and there's straight up no way to set the version (currently) without explicitly modifying project.json. |
I'd say that if you can find a way to get GitVersion working, then that'd be awesome! |
@onovotny actually SimpleGitVersion (see here) did the job well ... for dnx. What it does is:
It worked like a charm (just like the SimpleGitVersionTask does the job for msbuild).... but now I have to find time to see how I could adapt it to work on dotnet... :( |
Oh...this may be easier than we all thought. CLI works differently than DNX. It does not produce a nupkg file directly on build. There are two commands for that --
If you never call pack, you won't get a nupkg out of it. Point is, that if you have a pre/post-build script in the project.json that calls gitversion, and that script updates the version in the project.json itself, then there's a good chance that |
@onovotny If I'm not totally mistaken then changing the |
@sunsided that's entirely possible, I was just guessing since build/pack were split into two steps. |
I might have a crack at this. I am currently thinking to expose "commands": {
"gitversion": "GitVersion.Commandline /updateprojectjson"
}, Then in any "commands": {
"replace-version": "GitVersion.Commandline"
}, The idea is that at the start of your build, you would only need to execute a I thought about this for a little bit and I though this was better than having to execute Feedback welcome before I start any action this. Perhaps there is a simpler way that I am not seeing. So the build process would become:
|
Ooo I have thought of a way to make that a bit better. The "dummy" command could be used to carry format params for how you'd like GitVersion to replace the version in the project.json. i.e:
|
@dazinator It's awesome that you want to tackle this. But will the end solution only work with |
Meant to post this earlier, but I would not invest any time or effort into a DNX based solution. It will almost immediately be rendered obselete once Dotnet CLI RCs. |
Was just about to say this - |
It doesn't, or at least not in the same way that Dnx does. |
@dazinator I don't know how relevant GitVersionTask is going to be if the only way to version assemblies is to inject a version number into |
There's absolutely no reason for GitVersionTask to go away. All we're talking about are xproj; csproj still works just fine with GitVersionTask and csproj/msbuild isn't going anywhere. |
@onovotny Ok, I thought perhaps |
There's quite a lot of things that xproj does not support. WPF needs targets to compile BAML; UWP needs targets for x:Bind and a whole lot of other things; Xamarin projects need targets for their builds. Pretty much any non-trivial build phase needs targets, and MSBuild is how you get there. xproj/project.json so far is really only good for "basic"/simple projects. Not that it's a bad thing, and it covers a lot. But build is far more than calling the resx compiler and csc. |
A small announcement that may interest some of you. Some details here: HTH... |
@sunsided, you are right to worry about:
Fortunately this is only a warning, not an error and everything works fine. @onovotny, its true that:
This is what we do in SGV: all the cross references between local project.json files are updated: |
With the advent of the preview1
by e.g. specifying something like
per project, where That said, in the recent community standups it was made clear that |
I'm happy to take on the creation of a |
So, I've found that changing the |
@droyad i built a simple proof of concept a bit ago: https://github.com/ah-/dotnet-gitversion |
@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. |
Ah, I just found libgit2/libgit2sharp.nativebinaries#39 |
@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 |
Is there anyway we could just wrap the already compiled exe, because it is cross platform via mono. |
@JakeGinnivan agree, unlisted LibGit2Sharp.NativeBinaries-dotnet as that's now fixed upstream. 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. |
I was thinking wrapping, so create a native .net cli app which simply shells out to gitversion? |
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? |
@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 ... |
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. |
@bravecobra How do you mean? I've been using the following syntax to reference other projects:
|
@droyad I didn't know you could to that. Tnx! |
Use PreBuild task / command-line GitVersion as a workaround (Windows only) dotnet/sdk#1055 (comment) Don't generate .nupkg on build
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.The text was updated successfully, but these errors were encountered: