locked
[UWP] How to change app version through MS build. RRS feed

  • Question

  • Hi

    We are creating automated UWP build through Jenkins.

    We want to change app version to any version number(may not be sequential) through MS build. 

    How we could achieve this?

    Regards

    Sandeep


    sandeep chauhan

    Thursday, May 16, 2019 1:30 PM

All replies

  • Hi ,

    Since the problem is more related to MSBuild, I'll help you to move this thread to the MSBuild Forum. You could get more professional support about MSBuild.

    Thank you for your patience.

    Best regards,

    Roy

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 17, 2019 2:49 AM
  • Hi Sandeep_chauhan,

    Sorry for delay in reply.

    According to your requirement, I suggest you could use MSbuild Community Tasks tool. It will generate a new Assemblies.cs file with new version number to overwrite an old one. Please refer the below steps to implement this.

    >1 download and install the tool from this page

    >2 open your .csproj file as text, then import the targets and add the sample property below:

    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
    
    <Target Name="BeforeBuild" >
        <AssemblyInfo CodeLanguage="CS"  
                OutputFile="./Properties/AssemblyInfo.cs" <!--directory of your assembly file--> 
                AssemblyVersion="$(VersionNumber)" 
                AssemblyFileVersion="$(VersionFileNumber)" />
    </Target>

    >3 open Visual Studio 2017 Developer Command Prompt, type the sample command

    msbuild [soluiton file] -p:VersionNumber=2.0.0.0 ...

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, May 20, 2019 8:17 AM
  • Hi Dylan

    Thanks for reply!

    #1 I downloaded  MSbuild Community Tasks tool.

    #2 Copied and paste into my .csproj file. (removed commented line <!--directory of your assembly file--> )

    #3 Run following command on Visual Studio 2017 Developer Command Prompt

       msbuild D:\Windows_Projects\PanasonicDigitalSignage\PanasonicDigitalSignage.sln -p:VersionNumber=2.0.0.0

    command ran successfully but not found version 2.0.0.0 in manifest file or any other files of my solution.

    Also after doing #2 when I build my project it gives error -

    No assembly parameter were set for file "./Properties/AssemblyInfo.cs".



    Regards 
    Sandeep
    Tuesday, May 21, 2019 12:28 PM
  • Hi Sandeep_chauhan,

    Sorry for my mistake.

    Please run Visual Studio 2017 Developer Command Prompt as administrator.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, May 22, 2019 6:28 AM
  • Hi Dylan

    Thanks for your suggestion! 

    Able to change the AssemblyVersion in AssemblyInfo.cs file by running the command after opening Visual Studio 2017 Developer Command Prompt as administrator.

    But seems there is no use of this as per my requirement.

    Actually this is not effecting to manifest version,

    Also when I build my project, getting below error.

    No assembly parameter were set for file "./Properties/AssemblyInfo.cs".

    My requirement is when I create app package of my solution then the version of my build should be same as the version I am passing through command.


    sandeep chauhan




    Wednesday, May 22, 2019 10:06 AM
  • Hi Sandeep_chauhan,

    Sorry for this misunderstanding.

    >>Actually this is not effecting to manifest version,

    After my research and experiments, the manifest version is a value which is set in the Package.appxmanifest file, and msbuild could not support modifying this file. Then I have a try to convert the .appxmanifest file to .xml file, and use powershell to modify this file. But it also fails.

    >>No assembly parameter were set for file "./Properties/AssemblyInfo.cs"

    The previous suggestion is to build the app with modifying assembly version number through msbuild, so in the msbuild we should build the project with this settings all the time 

    msbuild [soluiton file] -p:VersionNumber=2.0.0.0 + other parameter settings

    If build in the visual studio, please delete or comment off the code which is added in the csproj file.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Thursday, May 23, 2019 4:30 AM