5

In the .net core 2.1 project, there is a *.csproj file, that contains assembly information:

<PropertyGroup>
    <AssemblyVersion>2019.1.15341.0</AssemblyVersion>
    <FileVersion>2019.1.15341.0</FileVersion>
    <Version>2019.1.15341</Version>
</PropertyGroup>

In Standard .net projects there were Properties/AssemblyInfo.cs which contained the Assembly information, but in the .net core, there is no AssemblyInfo.cs, all Assembly information are in the csproj.

How can I change the Assembly Version, File Version in Assembly Info Patcher in TeamCity for the .net core projects?

1
  • 1
    Are you using the dotnet runner to build the project in Team City, if yes then just pass the /p:Version as a command line param and that should version the output libraries
    – Rajesh
    Commented Jul 16, 2018 at 15:54

3 Answers 3

4

You can use File Content Replacer build feature with predefined templates for .NET Core

https://www.jetbrains.com/help/teamcity/file-content-replacer.html#.NET+Core+csproj+templates

1
2

Using /p switch didn't work for my. However -p works just fine

dotnet build -p:Version=1.2.3.4

You can also apply the same switch to the dotnet pack

dotnet pack Yourproject.csproj -p:Version=1.2.3.4

look at this page https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#msbuild for details.

1

Just in case anyone misses it, Rajesh commented above that if using the .NET CLI Runner you can simply add this to the Command line parameters option for the build step:

/p:Version=%build.number%

..and it'll version all the binaries for you. This worked for me and seems simpler than configuring the File Content Replacer as above.

I've added this as it seems to be a perfectly acceptable answer, and because Rajesh's comment didn't give full details (pointed me in the right direction though)

1
  • Wow great! This is simple. Will try in next project. Till then can you provide documentation for it ?
    – Gour Gopal
    Commented Jun 21, 2019 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.