Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Support .NET Core projects #18

Closed
ygoe opened this issue Jun 30, 2017 · 2 comments
Closed

Support .NET Core projects #18

ygoe opened this issue Jun 30, 2017 · 2 comments
Assignees

Comments

@ygoe
Copy link
Owner

ygoe commented Jun 30, 2017

.NET Core projects (.csproj) in Visual Studio 2017 (15.3) define the assembly and NuGet package version inside the .csproj file instead of a separate .cs file with assembly attributes. NetRevisionTool should detect these situations and patch the project file instead (hopefully that works because the tool will be called from build events defined in the same file). This includes the NuGet package version.

Example project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <Version>1.0.0-rc</Version>
    <AssemblyVersion>1.1.0.0</AssemblyVersion>
    <FileVersion>1.2.0.0</FileVersion>
    <InformationalVersion>1.3-rc</InformationalVersion>
  </PropertyGroup>
</Project>
  • "1.0.0-rc" is the NuGet package version (string)
  • "1.1.0.0" is the assembly version
  • "1.2.0.0" is the file version
  • "1.3-rc" is the assembly informational version (string)

The version properties can be added at the end of the .csproj file in a separate unconditional <PropertyGroup> and override whatever was defined in the project before (if anything).

The version format string can be defined in a custom XML element like <VersionFormat>. So the format is no longer defined and resolved in place but rather read from a separate location and added as new the version elements.

@ygoe
Copy link
Owner Author

ygoe commented Jun 30, 2017

Or better yet, NetRevisionTol should finally fully integrate with MSBuild to properly handle this valid project definition:

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net40</TargetFrameworks>
    <Version>1.0.0</Version>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
    <Version>1.0.2-net40</Version>
  </PropertyGroup>
  <PropertyGroup>
    <InformationalVersion>$(Version)</InformationalVersion>
  </PropertyGroup>

The revision number format would be defined in an MSBuild variable and could be customised for arbitrary conditions. The final version number/string would be provided in an MSBuild variable.

That would make a new major version 3.0 which probably drops support for AssemblyInfo files and can only be used for the new MSBuild projects.

@ygoe
Copy link
Owner Author

ygoe commented Feb 3, 2018

.NET Revision Task for MSBuild is available here: https://github.com/ygoe/NetRevisionTask

@ygoe ygoe closed this as completed Feb 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant