2009-09-03 163 views
3

有沒有可視化的方法  Studio   2008從命令行執行「Publish Now」按鈕?從命令行發佈ClickOnce

我見過的帖子建議使用msbuild/target:發佈來調用它。這沒什麼,但是MSBuild不增加版本號。我希望這樣的事情:

devenv mysolution.sln /publish 

回答

3

爲了增加內部版本號,我使用我的MSBuild Extension pack .csproj的文件中,如下所示:

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

這樣,無論何時在配置設置爲釋放 - VersionIncrement,版本號被改變。當做到這一點,我可以使用下面的MSBuild命令發佈:

的MSBuild C:\項目\ MyProject.csproj /噸:ResolveReferences; _CopyWebApplication /P:配置=釋放; BuildingProject = TRUE; WebProjectOutputDir = C:\的Inetpub \ wwwroot的\ OutputProject \ MyProjectOutput; OUTDIR = C:\的Inetpub \ wwwroot的\ OutputProject \ MyProjectOutput

注意,這是爲ASP.NET 3.5 Web應用程序。