Skip to content

Support for dotnet (prev. DNX) / .NET Core projects #647

Closed

Description

@sunsided

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.

Activity

  1. gep13 commented on Sep 17, 2015

    @gep13
    Member

    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.

  2. pascalberger commented on Sep 17, 2015

    @pascalberger
    Member

    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)

  3. dazinator commented on Sep 17, 2015

    @dazinator
    Contributor

    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..

  4. sunsided commented on Sep 17, 2015

    @sunsided
    Author

    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.

  5. gep13 commented on Sep 17, 2015

    @gep13
    Member

    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.

  6. sunsided commented on Sep 20, 2015

    @sunsided
    Author

    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):

    "dependencies": {
            "xunit": "2.1.0-*",
            "xunit.runner.dnx": "2.1.0-*"
        },
    "commands": {
            "test": "xunit.runner.dnx"
        }

    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.

  7. clairernovotny commented on Oct 20, 2015

    @clairernovotny

    There are now support for pre/post build script commands in beta 8 of the DNX tooling. This may be possible now....

  8. olivier-spinelli commented on Nov 2, 2015

    @olivier-spinelli

    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).

  9. sunsided commented on Nov 2, 2015

    @sunsided
    Author

    Crap, sorry, accidentally hit the close button.

  10. RichiCoder1 commented on Mar 10, 2016

    @RichiCoder1

    Any update? I might be interested in taking this up.

  11. clairernovotny commented on Mar 10, 2016

    @clairernovotny

    @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?

  12. 23 remaining items

  13. ah- commented on Jul 28, 2016

    @ah-
  14. JakeGinnivan commented on Aug 14, 2016

    @JakeGinnivan
    Contributor
  15. JakeGinnivan commented on Aug 14, 2016

    @JakeGinnivan
    Contributor
  16. JakeGinnivan commented on Aug 14, 2016

    @JakeGinnivan
    Contributor

    @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

  17. JakeGinnivan commented on Aug 14, 2016

    @JakeGinnivan
    Contributor

    Is there anyway we could just wrap the already compiled exe, because it is cross platform via mono.

  18. ah- commented on Aug 14, 2016

    @ah-

    @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.

  19. JakeGinnivan commented on Aug 15, 2016

    @JakeGinnivan
    Contributor

    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?

  20. dazinator commented on Oct 23, 2016

    @dazinator
    Contributor

    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?

  21. sunsided commented on Oct 23, 2016

    @sunsided
    Author

    @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 ...

  22. bravecobra commented on Nov 10, 2016

    @bravecobra

    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.

  23. droyad commented on Nov 10, 2016

    @droyad

    @bravecobra How do you mean? I've been using the following syntax to reference other projects:

    "dependencies": {
        "MyOtherProject": {
          "target": "project"
        }
      },
    
  24. bravecobra commented on Nov 10, 2016

    @bravecobra

    @droyad I didn't know you could to that. Tnx!

  25. asbjornu commented on Mar 1, 2019

    @asbjornu
    Member

    .NET Core support (.NET Standard 1.3) was added in #1269, .NET Core 2.1 (.NET Standard 2.0) support in #1422.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions