I have set up my build on Visual Studio Team Services but looks like that the Web.config transformation of my Web.Release.config doesn't work and I receive only the standard Web.config. What I do wrong or what parameter I miss.
Asked
Active
Viewed 1,543 times
0

jessehouwing
- 106,458
- 22
- 256
- 341

cpiock
- 1,275
- 2
- 17
- 44
-
I have never played with it with the TFS build but inside visual studio the transform only gets applied when you do a `Deploy` the config that is created when you just do a `Build` is the untransformed version. – Scott Chamberlain Jan 11 '17 at 16:36
-
it runs a command like this msbuild.exe "myProject.sln" /p:Configuration=Release /p:platform="Any CPU" /p:VisualStudioVersion="15.0" – cpiock Jan 11 '17 at 16:42
-
See this quuestion and answer http://stackoverflow.com/questions/13920146/using-msbuild-exe-to-publish-a-asp-net-mvc-4-project-with-the-cmd-line – Scott Chamberlain Jan 11 '17 at 16:44
2 Answers
3
For the transformation to happen msbuild needs to "deploy" the solution. I am not sure of the most correct way to do it, but a easy workaround would be add
/p:DeployOnBuild=true /p:PublishProfile=SomeProfile
to the MSBuild Arguments option. You can then grab the files from wherever you configured the publish profile to put them and use those during your deployment.
Here is a very simple example of a SomeProfile.pubxml
file that would put the published files in the artifact staging directory.
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>$(BUILD_ARTIFACTSTAGINGDIRECTORY)\Release</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
Using the MSBuild command args in TFS
/p:DeployOnBuild=true /p:PublishProfile=SomeProfile
dropping the /p:outDir
.

Luca Cappa
- 1,925
- 1
- 13
- 23

Scott Chamberlain
- 124,994
- 33
- 282
- 431
-
hmm on my build server i don't need a publishprofile because the copy to the azure server does the Release Management of Visual Studio Team Service – cpiock Jan 11 '17 at 17:05
-
Perhaps create a profile that drops the transformed files in to `$(BuildArtifactStagingDirectory)\Release` and get rid of the `/p:outDir` in your build step. Profiles are just MSBuild scripts themselves and should be able to use the global variables. – Scott Chamberlain Jan 11 '17 at 17:11
-
ok. locally by setting a fixed path it works. how can i set the $(BuildArtifactStagingDirectory) in the profile configuration? – cpiock Jan 11 '17 at 17:23
-
@cpiock added a example pubxml file that should work. Just create a new profile from inside visual studio then open the pubxml file and edit it as needed to have the settings you want. – Scott Chamberlain Jan 11 '17 at 17:34
0
The profile want work for me on the build server. I found this solution that works for me.
/p:outdir=$(build.artifactstagingdirectory)\Release /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false
This part makes the difference:
/p:UseWPP_CopyWebApplication=true

cpiock
- 1,275
- 2
- 17
- 44
-
Since you solved the issue by yourself, you can mark it as answer. – starian chen-MSFT Jan 16 '17 at 06:01