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

<pre><code>dotnet build -p:Version=1.2.3.4
</code></pre>

<p>You can also apply the same switch to the dotnet pack</p>

<pre><code>dotnet pack Yourproject.csproj -p:Version=1.2.3.4
</code></pre>

<p>look at this page <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#msbuild" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#msbuild</a> for details.</p>

CC BY-SA 4.0
2019-10-31T00:29:58.863Z
2019-10-31T00:29:58.863Z
Alex Eyhorn
<p>Just in case anyone misses it, Rajesh commented above that <em>if using the .NET CLI Runner</em> you can simply add this to the <strong>Command line parameters</strong> option for the build step:</p>

<pre><code>/p:Version=%build.number%
</code></pre>

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

<p>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)</p>

CC BY-SA 4.0
2019-06-21T11:22:35.447Z
Wow great! This is simple. Will try in next project. Till then can you provide documentation for it ?
Gour Gopal
CC BY-SA 4.0
2019-06-17T12:54:17.883Z
2019-06-17T12:54:17.883Z
GPW
<p>You can use <code>File Content Replacer</code> build feature with predefined templates for .NET Core</p>
<p><a href="https://www.jetbrains.com/help/teamcity/file-content-replacer.html#.NET+Core+csproj+templates" rel="nofollow noreferrer">https://www.jetbrains.com/help/teamcity/file-content-replacer.html#.NET+Core+csproj+templates</a></p>

CC BY-SA 4.0
2019-03-22T10:50:02.003Z
Please see this answer for how to do this: https://stackoverflow.com/a/51190626/894792
Luke
CC BY-SA 4.0
2018-08-27T22:03:15.773Z
2021-05-10T08:38:38.777Z
2021-05-10T08:38:38.777Z
olsh
<p>In the .net core 2.1 project, there is a <code>*.csproj</code> file, that contains assembly information:</p>

<pre><code>&lt;PropertyGroup&gt;
    &lt;AssemblyVersion&gt;2019.1.15341.0&lt;/AssemblyVersion&gt;
    &lt;FileVersion&gt;2019.1.15341.0&lt;/FileVersion&gt;
    &lt;Version&gt;2019.1.15341&lt;/Version&gt;
&lt;/PropertyGroup&gt;
</code></pre>

<p>In Standard <strong>.net</strong> 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.</p>

<p>How can I change the Assembly Version, File Version in Assembly Info <strong><em>Patcher</em></strong> in <strong><em>TeamCity</em></strong> for the <strong>.net</strong> core projects?</p>

CC BY-SA 4.0
2018-07-16T15:54:24.223Z
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
<teamcity>
How to patch AssemblyInfo in TeamCity for .net core 2.1 projects?
Gour Gopal
# How to patch AssemblyInfo in TeamCity for .net core 2.1 projects?

(Asked by: username_0 on 2018-07-05)

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

    2019.1.15341.0
    2019.1.15341.0
    2019.1.15341


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?

**Tags:** teamcity

> **Comments:**
> **username_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  

---

## 3 answers

### Answer by username_4 on 2018-08-27. Score: 4 | Accepted answer

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>

> **Comments:**
> **username_5**: Please see this answer for how to do this: https://stackoverflow.com/a/51190626/894792  

---

### Answer by username_2 on 2019-10-31. Score: 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.


---

### Answer by username_3 on 2019-06-17. Score: 1

Just in case anyone misses it, username_1 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 username_1's comment didn't give full details (pointed me in the right direction though)

> **Comments:**
> **username_0**: Wow great! This is simple. Will try in next project. Till then can you provide documentation for it ?  

---

