Are there good patterns for mapping solution configurations to environments and using MsDeploy for packaging per environment?
Shortest version: Grab this file, and try t
The first attempt failed because Package target doesn't exist in the solution file. When using MSBuild on a solution file, a temporary MSBuild project is created (SamplePackage.sln.metaproj); this project file contains only some targets (Build, Clean, Rebuild, Publish, ...)
One way to do what you want is to use DeployOnBuild property like this :
<PropertyGroup Condition="'$(Configuration)' == ''">
<Platform>Any Cpu</Platform>
<Configuration>Dev</Configuration>
<PackageLocation>$(MSBuildProjectDirectory)\package.zip</PackageLocation>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="SamplePackage.sln"
Targets="Build"/>
</Target>
<Target Name="BuildWebPackage">
<MSBuild Projects="SamplePackage.sln"
Properties="Platform=$(Platform);
Configuration=$(Configuration);
DeployOnBuild=true;
DeployTarget=Package;
PackageLocation=$(PackageLocation);"/>
</Target>
Additional links :
I've done something similar that may be useful. In a recent project, we had 'Dev', 'Test' and 'Prod' environments.
I added solution configurations for each of these.. eg.
For most projects in the solution, these configurations were just linked to the regular 'Release' build, but where appropriate, some projects did have distinct 'Release-Test' build configurations where there might be #if/#endif stuff in the code.
This would also make sense to allow customisation for your msdeploy config per configuration too.
Regarding the msbuild target. The target referrs to the name of a element. eg you could call msbuild with /t:BuildWebPackage for your example above.