views:

344

answers:

1

Is there a way to have VS.NET 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
+2  A: 

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

<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 Configuratin 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 ASP.NET 3.5 web application.

laconicdev