Reputation: 3996
I have a Visual Studio solution with multiple webapp projects. The build should create a web package for each project. The web packages should finally end up in a folder structor like this:
$(Outputfolder)
|
+-- Web
|
+-- <name package 1>
| |
| +-- ... package files ...
|
+-- <name package 2>
| |
| +-- ... package files ...
|
+-- ...
|
In order to change the destination folder for a web package I have added a .wpp.targets file to each web app project. Here I have adjusted the DefaultPackageOutputDir property:
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefaultPackageOutputDir Condition=" '$(DefaultPackageOutputDir)'=='' ">$(OutFolder)Web\Webapp1\</DefaultPackageOutputDir>
</PropertyGroup>
</Project>
This is it how I call MSBuild. I simply hand over the output folder as a property:
<MSBuild Projects="@(ItemToBuild)"
Targets="Build"
Properties="Configuration=$(Configuration);
Platform=$(Platform);
DeployOnBuild=True;
DeployTarget=Package;
OutFolder=$(OutFolder)" />
This does the trick but I'm not completely satisfied. I want to make the build more general. It bothers me, that I have to name the webapp explicitly. My idea was to use the property DefaultMSDeployDestinationApplicationName instead:
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefaultPackageOutputDir Condition=" '$(DefaultPackageOutputDir)'=='' ">$(OutFolder)Web\$(DefaultMSDeployDestinationApplicationName)\</DefaultPackageOutputDir>
</PropertyGroup>
</Project>
Unfortunately the property DefaultMSDeployDestinationApplicationName seems to be empty. The package files end up in the Web folder. I guess the property DefaultMSDeployDestinationApplicationName is not yet defined at the time the .wpp.targets file is readed.
Does somebody know a better place to define the property DefaultPackageOutputDir?
Upvotes: 2
Views: 2576
Reputation: 1270
I was able to change the output directory for a Web Project by specifying the following options to MsBuild:
/p:OutDir="$(build.artifactstagingdirectory)\$(BuildConfiguration)" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true
Upvotes: 1