0
votes

I have a TFS build that needs to apply web.config transformations. I have it configured with the following MSBuild parameters:

/p:DeployOnBuild=true /p:DeployTarget=Package /p:OutDir=$(build.artifactstagingdirectory) /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false

When running the step with Visual Studio 2015, the build works as expected - I get the transforms applied and packages created.

When running the step with Visual Studio 2017, no transforms are applied and no packages created.

Is there another way to configure the build with VS2017 so that config transforms are applied?

2
Are you using the SDK builds when compiling with VS 2017 or using the old style csproj file?Hamid Shahid
I'm running a TFS build that uses VS2017. It, in turn, executes a command using "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" and passing in the solution path, my parms, etc.Zaneta
I get that but did you change your csproj file to the new style MSBuild?Hamid Shahid
No, what is the new style? Just a clarification, this is not a .net core project. It's a solution with a couple of web applications and a windows service.Zaneta
You can still use SDK style build with .net projects that's why I asked. Looks like you didn't change the build to use something like <Project Sdk="Microsoft.NET.Sdk"> I compare the TransformXml task in the Microsoft.Web.Publishing.Tasks.dll library for each version of MsBuild. There is not a lot different there to suggest that anything drastic would changed. can you share your csproj file pleaseHamid Shahid

2 Answers

0
votes

According to your description and Hamid's comment. This may related to your .csporj file. You could try to build the project directly on the build agent with build service account to narrow down the issue if related to TFS side.

If build locally also got the same error, try below solution:

  1. Open the project file (.csproj) of the project failing to load

  2. Search for <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />

  3. Change it to <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.targets" />
  4. Reload the project

That will set the correct version of Visual Studio dynamically and properly.

Also take a look at this blog: Cannot open VS 2015 Web project in VS 2017 which be helpful show you how to deal with old 2015 project in VS2017.

0
votes

The only way I was able to make this work is to either run the build using VS 2015 or using MSBuild and pass /p:VisualStudioVersion="14.0" as a parameter. With this, VS 2015 target files need to be on the build server as well.