开发者

How to specify Publish Version in Devenv?

I am totally new in building Visual Studio Project through a script, so feel free to correct me if you feel that my understanding about the process is incorrect.

I have a visual studio solution which consists of a Wpf.exe project and few class library projects.

Currently I am successfully building .sln file using script below

"%VS_IDE_DIR%devenv.com" "...Solution-File-Path.sln" /rebuild Release /useenv

开发者_如何学JAVACurrently the Wpf.exe file gets the File Version and Product Version 1.0.0.0 which is the default specified in Publish -> Publish Version Property of Wpf project.

How to specify Publish Version in Devenv?

I want to somehow set the File Version and Product Version through my script. How can I achieve that?

I have an environment variable which contains the Product Version and File Version, Basically I want to set value of Product Version and File Version equal to my environment variable.


There's a simple way to do this. In the WPF project, open the Properties node and double-click AssemblyInfo.cs. The [assembly: AssemblyFileVersion] attribute sets the File Version number. Add this to set the Product Version number:

[assembly: AssemblyInformationalVersion("1.2.3.4")]

Doing this from the command line is only technically possible. You'd have to create the native file version resource and compile it with rc.exe. And use Project + Properties, Resource file option to tell the compiler to use the custom .res file produced by rc.exe. You'd need scripting to get the version resource updated. Given how easy it is to do this by editing AssemblyInfo.cs, I'd recommend you don't bother.


You can add /p:ApplicationVersion=1.0.0.1 while running the ms build command. The version number specified will be the version number the project will use while compiling the exe.

Update:

I have added the following xml code inside the project tag to the project file of my solution.

<ItemGroup>
<Tokens Include="ApplicationVersion">
      <ReplacementValue>$(ApplicationVersion)</ReplacementValue>
      <Visible>false</Visible>
</Tokens>
 </ItemGroup>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜