I have a problem with the 'visual studio build'-task on a TFS 2015 build server. When I build my project on the buildserver it doesn't publish the transformed web.config to the correct folder. I have two web.configs --> web(base).Debug.config and web(base).Release.config.
In the following folder I expect the transformed web.config: : ...\TFS2015BuildAgent\work{tasknummer}\a_PublishedWebsites{backend solution}\web.config However the transformed web.config is in the following folder: ...\TFS2015BuildAgent\work{tasknummer}\a_PublishedWebsites\web.config
The solution.csproj -file has the following lines:
...
...
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
...
...
...
<Target Name="PostTransformAppConfig" AfterTargets="Build">
<CallTarget Targets="TransformWebConfig" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="Web.config" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="$(OutDir)\Web.config" />
<Copy Condition="Exists('$(TransformWebConfigIntermediateLocation)\transformed\webbase.config')" SourceFiles="$(TransformWebConfigIntermediateLocation)\transformed\webbase.config" DestinationFiles="$(OutDir)\_PublishedWebsites\$(AssemblyName)\Web.config" />
</Target>
...
...
...
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" Condition="false" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<PropertyGroup>
<PreBuildEvent>attrib -R "$(ProjectDir)Web.config"</PreBuildEvent>
</PropertyGroup>
Below the specs of the Visual Studio Build task on the TFS server:
- visual studio version: Visual Studio 2017
- MSBuild Arguments: /p:OutDir=$(build.stagingDirectory) /p:SkipInvalidConfigurations=true /p:AllowedReferenceRelatedFileExtensions=none /p:DeployOnBuild=true
- Platform: any cpu
- Configuration: release
- Clean: true
- MSBuild Architecture: MSBuild x86
When I build my project (local) in VS 2017, the web.config is correctly transformed. Also when publishing it local, the web.config is correctly transformed according de Debug or Release config.
However I have created multiple build defenitions for other projects on this TFS server, including transforming the web.config. On all other project the web.config files are transformed correctly/as expected....
So I am probably missing something.... but what?