简体   繁体   中英

Specify the assembly version for a DotNet Framework 4.7 project using msbuild via PowerShell

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.

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM