How to get version number in post-build event

后端 未结 4 1966
遥遥无期
遥遥无期 2021-02-01 22:44

I want to use post-build event to automatically create a nuget package and then copy it to a shared folder on our network, something like this (the version number 1.0.0.0. is sp

4条回答
  •  梦谈多话
    2021-02-01 23:07

    I tried what giammin suggested, and with a few tweaks got this working for me:

    
        
           
        
        
    
    

    I added the "Condition attribute so that I could specify when I would have this built to a specific location (in my case creating a backup for rollbacks). Also, the "xcopy" was giving me errors...but a normal "copy" was not.

    Then, in my post-build event I have something like this:

    copy $(TargetDir)*.dll \\dev-server\folder
    
    IF NOT "$(ConfigurationName)" == "Stage" EXIT
    
    mkdir "$(ProjectDir)Versions"
    copy /Y "$(TargetPath)" \\stage-server\folder
    

    I hope that all helps in some way.

    Note that the post-build event is executed BEFORE the "AfterBuild" element of the csproj XML.

    So you could just use in you post build event: nuget.exe pack "$(SolutionDir)MyLib.nuspec" and add the afterbuild element for the copy and you should be fine.

提交回复
热议问题