Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-31T00:29:58.863Z
Answers: 2019-10-31T00:29:58.863Z
Answers: Alex Eyhorn
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2019-06-21T11:22:35.447Z
Answers: Wow great! This is simple. Will try in next project. Till then can you provide documentation for it ?
Answers: Gour Gopal
Answers: CC BY-SA 4.0
Answers: 2019-06-17T12:54:17.883Z
Answers: 2019-06-17T12:54:17.883Z
Answers: GPW
Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2019-03-22T10:50:02.003Z
Answers: Please see this answer for how to do this: https://stackoverflow.com/a/51190626/894792
Answers: Luke
Answers: CC BY-SA 4.0
Answers: 2018-08-27T22:03:15.773Z
Answers: 2021-05-10T08:38:38.777Z
Answers: 2021-05-10T08:38:38.777Z
Answers: olsh
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2018-07-16T15:54:24.223Z
Comments: 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
Comments: Rajesh
Tags: <teamcity>
Title: How to patch AssemblyInfo in TeamCity for .net core 2.1 projects?
UserDisplayName: Gour Gopal
ThreadText: # 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:
  
  ```
  <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?
  
  **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 ?  
  
  ---
  
  