Reputation: 581
There are multiple c# class library (DotNet Core 2.1) projects and User Interface (WPF project) in my solution.
Let say a class library project properties have Assembly version 2019.1.15341.0:
Also, the same Assembly version is assigned to the user interface (WPF application):
[assembly: AssemblyVersion("2019.1.15341.0")]
[assembly: AssemblyFileVersion("2019.1.15341.0")]
In TeamCity, I have configured AssemblyInfo Patcher:
I build the complete solution using TeamCity and the builds were successful:
Now let's see the property of artifacts produced after Building the complete solution:
1. Project 1 (Class library, DLL properties):
2. UserInterface (WPF project):
I see that the UserInterface.exe's Version
has been changed by TeamCity according to it's build counter
and build vcs number
, but Why the DLL's version
is not changed? Am I missing any steps? or anything else?
Any information I am missing please inform.
The properties of EXEs seems fine as expected. The main concern is on the DLLs: It's property is not getting changed.
Upvotes: 6
Views: 3625
Reputation: 581
As mentioned it is a .Net Core
project, so it may not be having an AssemblyInfo.cs
where Assembly properties are defined.
So go to Build Features in TeamCity, and add a Build Feature.
<Version>\S*<\/Version>
or use template regex: (<(Version)\s*>).*(<\/\s*\2\s*>)
I have used Replace With: <Version>%MAJOR%.%MINOR%.%build.counter%.%build.vcs.number%</Version>
so that <version>
and </version>
tags don't get deleted as per my regex. It all depends on your regex what you need to replace.
Similarly, I have added other required parameters:
Pros: After building the project I can see the expected results in properties.
Cons: Searches and Replaces the files multiple times and not once (the number of Build features, the same number of time it will be executed, and the same number of time it will be reverted!)
Upvotes: 11
Reputation: 32250
According to the TeamCity AssemblyInfo patcher docs:
...after this build feature is configured, it will run before the first build step. TeamCity will first perform replacement in the files found in the build checkout directory and then run your build.
However, the values you have on the Package tab of the DLL projects' settings (your first screenshot) are applied during the build process itself, that is when MSBuild processes your projects. I suspect the values set by TeamCity Assembly patcher are replaced back to defaults here.
Upvotes: 2