7
votes

We made the switch to Visual Studio 2017 and having trouble with our self-hosted build agent that gets its work from VSTS.

One VSTS-build step is building all solutions with "Visual Studio Build: Build Solution ***.sln" using "Visual Studio Version: Visual Studio 2017".
The following error happens for all our projects where "ASP.NET Core Web Application (.NET Core)" was the chosen project type.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(54,5): error MSB4062: The "TransformWebConfig" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0....\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Additional information:

  • From within Visual Studio 2017 the solutions built without any errors.
  • None of our projects include any .config transformations files (but do include .config files like web.config), still the error occurs.
  • Visual Studio 2017 Build Tools as well as full Visual Studio 2017 have been installed on the build server and e.g. .NET Core Class Libraries compile fine.
  • Installed .NET Core versions are identical between build server and developer machines.
  • The same errors also happen when using "MsBuild: Build Solution ***.sln" as a build step for all solutions and selecting "MSBuild: MSBuild 15.0".
  • The file mentioned as "Could not load file or assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll" does exist in the mentioned path.
  • No tasks are defined within the .csproj files.

Anyone got any insight as to what might cause this?

2
What's the result if you run MSBuild command to build the solution manually?starian chen-MSFT
Based on the log, it is related to publish. Can you publish the web app (e.g. file system) through VS and MSBuild command?starian chen-MSFT
Yes, publishing from Visual Studio 2017 works.The shown error happens when executing the build step and because of the error the agent breaks before even getting to the step in the task group where publishing would be done.686d7066
@686d7066 what happens when you run the same MSBuild command line the CI runs on your dev box?Chris Patterson
I have had the same issue, with the MSBuild 15.0, digging a bit more, turns out that it is using the x64 version where this issue exist, so switching to the x86 version of the MSBuild 15.0 would have to work for you.Danko Valkov

2 Answers

0
votes

Have a look at this link. It looks like the issue was previously fixed

https://github.com/Microsoft/msbuild/issues/1010

However, recently another change was made to MSBuild (referenced from above). My hunch is this 'downgrade' is causing the 'fix' to be ignored (wrong DLL ver is being used)

https://github.com/aspnet/Scaffolding/pull/321

2
votes

Have a look below: https://github.com/aspnet/websdk/pull/174

I have reported the same behavior, and it turns out to be an issue only in the 64bit version of the MSBuild, switching back to the 32bit one worked for me, until this gets fixed.