从命令行发布ClickOnce

时间:2009-09-03 20:30:16

标签: visual-studio clickonce publish

有没有办法让Visual Studio 2008从命令行执行“立即发布”按钮?

我发过帖子建议使用 msbuild / target:publish 来调用它。没关系,但MSBuild不会增加修订号。我希望有类似的东西:

devenv mysolution.sln /publish

1 个答案:

答案 0 :(得分:4)

要增加内部版本号,我在.csproj文件中使用MSBuild Extension pack,如下所示:

<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>

这样,只要配置设置为Release-VersionIncrement,版本号就会更改。完成后,我可以使用以下MSBuild命令发布它:

  

msbuild c:\ projects \ MyProject.csproj   /吨:ResolveReferences; _CopyWebApplication   / P:配置=推出; BuildingProject = TRUE; WebProjectOutputDir = C:\的Inetpub \ wwwroot的\ OutputProject \ MyProjectOutput; OUTDIR = C:\的Inetpub \ wwwroot的\ OutputProject \ MyProjectOutput

请注意,这适用于ASP.NET 3.5 Web应用程序。