Publish ClickOnce from the command line

耗尽温柔 提交于 2019-12-03 13:51:16

问题


Is there a way to have Visual Studio 2008 execute the "Publish Now" button from the command line?

I've seen posts that suggest to use msbuild /target:publish to call it. That is OK, but MSBuild doesn't increment the revision number. I'm hoping for something like:

devenv mysolution.sln /publish

回答1:


To increment build numbers, I am using MSBuild Extension pack inside my .csproj file as follows:

<Target Name="BeforeBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release-VersionIncrement|AnyCPU' ">
  <CallTarget Targets="CleanAppBinFolder" />
  <MSBuild.ExtensionPack.VisualStudio.TfsSource TaskAction="Checkout" ItemCol="@(AssemblyInfoFiles)" WorkingDirectory="C:\inetpub\wwwroot\MySolution" ContinueOnError="true" />
  <!-- Microsoft's task that goes over assembly files and increments revision number. -->
  <MSBuild.ExtensionPack.Framework.AssemblyInfo Condition="'$(Optimize)'=='True' " AssemblyInfoFiles="@(AssemblyInfoFiles)" AssemblyRevisionType="AutoIncrement" AssemblyFileRevisionType="AutoIncrement">
    <Output TaskParameter="MaxAssemblyVersion" PropertyName="MaxAssemblyVersion" />
  </MSBuild.ExtensionPack.Framework.AssemblyInfo>
  <Message Text="----current version---: '$(MaxAssemblyVersion)'" />
</Target>

This way, anytime the configuration is set to Release-VersionIncrement, the version number is changed. When this is done, I can use the following MSBuild command to publish it:

msbuild c:\projects\MyProject.csproj /t:ResolveReferences;_CopyWebApplication /p:Configuration=Release;BuildingProject=true;WebProjectOutputDir=c:\inetpub\wwwroot\OutputProject\MyProjectOutput;OutDir=c:\inetpub\wwwroot\OutputProject\MyProjectOutput

Note that this is for an ASP.NET 3.5 web application.



来源:https://stackoverflow.com/questions/1375764/publish-clickonce-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!