0

I have this one liner that can publish my project:

& "$($linkToMSBuildEXE)" "$($solutionName)" /t:projectName /p:Configuration="Release"

I need to publish this project and set the assemblyVersion and fileVersion of the output executable. I have tried adding the version:

& "$($linkToMSBuildEXE)" "$($solutionName)" /t:projectName /p:Configuration="Release"/p:Version=1.1.1.1

This doesn't seem to work. Do I need to add an entry to the csproj file? How can I set the versions via the command line.

thatOneGuy
  • 9,977
  • 7
  • 48
  • 90
  • 1
    Please see the last answer here: https://stackoverflow.com/questions/8446693/specify-assembly-version-number-as-a-command-line-argument-in-msbuild – Dmitry Arestov Jan 07 '20 at 14:46
  • i came across that earlier, it seems convoluted to me, is there not a simpler way? I'm sure in dotnet core you can just specify /p:Version=1.2.3.4 – thatOneGuy Jan 07 '20 at 15:05

1 Answers1

1
  1. Install MSBuild.AssemblyVersion package from NuGet.

  2. Use the following or similar command line:

    msbuild project.csproj /t:Rebuild /p:AssemblyVersionNumber=1.2.3.4

Community
  • 1
  • 1
Dmitry Arestov
  • 1,427
  • 12
  • 24
  • that works perfectly. Thanks, I'm not sure why this isn't out of the box -.- – thatOneGuy Jan 08 '20 at 09:50
  • 1
    MSBuild is a powerful tool. In .NET Core, the successor of .NET, Microsoft guys decided to equip it with more handy tasks and features that are based on the same possibilities. – Dmitry Arestov Jan 08 '20 at 15:17