You can build the Publish target of a .csproj with the command-line MSBuild.exe, but when the Visual Studio IDE publishes a project it also copies it to a designated location and in Beta 2 appears to do something clever with preserving old .application manifests.
Is there a way to have MSBuild.exe perform these extra steps from the command line Perhaps I'm building the wrong target

Publishing a ClickOnce project with command-line MSBuild
Hany M. Magdy
<Project DefaultTargets="DoPublish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\lib\msbuild</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup Condition="!Exists('$(Configuration)')">
<Configuration>Debug</Configuration>
</PropertyGroup>
<PropertyGroup Condition="!Exists('$(CCNetLabel)')">
<CCNetLabel>0</CCNetLabel>
</PropertyGroup>
<PropertyGroup>
<ClickOnceBuildDirectory>AlgoCollateral\bin\$(Configuration)\AlgoCollateral.publish</ClickOnceBuildDirectory>
<Version>1.0.0.$(CCNetLabel)</Version>
<ClickOnceInstallDirectory>\\mtlv5webdev\Deployment\AlgoCollateral</ClickOnceInstallDirectory>
</PropertyGroup>
<ItemGroup>
<ClickOnceFiles Include="$(ClickOnceBuildDirectory)\**\*.*"/>
<IndigoServiceFiles Include="Algo.Collateral.Services\**\*.*"/>
</ItemGroup>
<Target Name="DoPublish">
<MSBuild Projects="AlgoCollateral.v5.sln" Targets="Clean;Build" Properties="ApplicationVersion=$(Version)"/>
<MSBuild Projects="AlgoCollateral/AlgoCollateral.csproj" Targets="Publish" Properties="ApplicationVersion=$(Version)" />
<!-- Write publish.htm file for ClickOnce -->
<Copy SourceFiles=".\Build\publish.htm" DestinationFiles="$(ClickOnceInstallDirectory)\publish.htm"/>
<Copy SourceFiles="AlgoCollateral\bin\$(Configuration)\AlgoCollateral.application" DestinationFiles="$(ClickOnceInstallDirectory)\AlgoCollateral.application"/>
<FileUpdate Files="$(ClickOnceInstallDirectory)\publish.htm"
IgnoreCase="true"
Multiline="true"
Singleline="false"
Regex="{VERSION}"
ReplacementText="$(Version)"
Force="true"/>
<!-- Move Click Once Files -->
<MakeDir Directories="$(ClickOnceInstallDirectory)"/>
<Copy SourceFiles="@(ClickOnceFiles)"
DestinationFiles="@(ClickOnceFiles->'$(ClickOnceInstallDirectory)\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>
</Project>
SHB
I'm also having trouble with the version number thingy. You can supply the version number as a parameter (not bad at all if you execute your msbuild from some other application, like NAnt). However, it doesn't really seem to care what version you supply, so I guess I've got it all wrong.
aing
--
Brady P. Merkel
Go Gators! --;==;<
TJM_MC
isjam
This answer is actually wrong...it will publish to the directory of your choice but it doesn't create the Publish.htm. The settings within a .csproj file are msbuild targets, tasks, and properties. The property for where to publish can be passed in.
This works fine:
<MSBuild Projects="@(ProjectsToBuild)"
Targets="Publish"
Properties="Configuration=$(Configuration);
Platform=$(Platform);
PublishDir=$(BuildDropLocation)\;
ApplicationVersion=$(ApplicationVersion);
PublisherName=$(Company);
PublishUrl=http://localhost/SmartClient/;
InstallUrl=http://localhost/SmartClient/">
<Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>
</MSBuild>
Since the property can be passed in via an MSBuild script then it can be passed in via commandline too.
-Ken Villines
Brian Rak
OliSchwarz
MSBuild won't actually perfom the publish (i.e. the physical transfer of files etc) when building from the command-line - as you've discovered. The simple reason is that the functionality to do that is in the IDE itself.
MSBuild will only perform the build related tasks.
Sorry!
..Kieran
David Lundell
Reed14676
I'm confused after having read through the above.
So, can I (or can I not) use MSBuild to publish my Win app to a specified URL
For our app, we must publish it to 10 different servers (10 different contained cattle feed yards). So I would love to have my version ready to be deployed, build it, and then go to the command prompt and be able to type something like:
msbuild /target:publish /property:PublishUrl=http://123.45.67.89/MyApp
msbuild /target:publish /property:PublishUrl=http://123.45.67.90/MyApp
msbuild /target:publish /property:PublishUrl=http://123.45.67.91/MyApp
etc
because then I could write a script to automate the publish to multiple locations instead of having to do it 10x in the VS IDE every time)
But from everything I'm reading, MSBuild will not publish to a URL, but only to a local folder. And it does not handle publish.htm and other needed files.
So should I abandon MSBuild or will it be able to do what I need
Thanks!
Ron
Amir Duany
I was wrong. Stupidity is a desease hard to cure, so please don't hit me. It'll only make it worse...
skayal
reevolution
C Davis