Specify publish version with MSBuild command line as assembly version of project

后端 未结 3 1136
无人共我
无人共我 2021-02-07 18:52

I have a simple batch file that I\'m running from a DOS command line that is used for building a small C# application that publishes a ClickOnce project. One line is this:

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 19:27

    In order to correctly update the version declared in the deployment manifest you need to modify the ApplicationVersion at the "AfterCompile" step rather than the "BeforePublish" step, since the application manifest is generated at build time. But then you can't rely on the $(TargetPath) property to point to the assembly and instead use the following path: $(ProjectDir)obj\$(ConfigurationName)\$(TargetFileName)

    So here's the updated Target code snippet that you can add to the .csproj file:

    
      
         
      
      
        %(AssemblyInfo.Version)
      
    
    

提交回复
热议问题