Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TransformWebConfig" task could not be loaded #1073

Closed
DixonDs opened this issue Apr 4, 2017 · 13 comments
Closed

"TransformWebConfig" task could not be loaded #1073

DixonDs opened this issue Apr 4, 2017 · 13 comments

Comments

@DixonDs
Copy link

DixonDs commented Apr 4, 2017

We experience this error when building new VS2017 csproj project with msbuild 2015:

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 <UsingTask> 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. 

Also it seems some other people experience it as well. See dotnet/msbuild#1010 and http://stackoverflow.com/q/42805862/213725

@senj
Copy link

senj commented Apr 5, 2017

It may be the same reason for a special case, but same is true for Service Fabric's *.sfproj projects.

@DankoValkov
Copy link

I am trying to build *.sfproj through MS Build 15.0 (15.1.548.43366) and get the same exception, the only difference seems to be that I am using the Enterprise version of Visual Studio 2017
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\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\Enterprise\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\Enterprise\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 <UsingTask> 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.

The actual command that is being executed seems to be the following:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe "*.sfproj" /nologo /nr:false /fl /flp:"logfile=path\file.log" /dl:CentralLogger,"path\1.0.45\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=..|SolutionDir=.."*ForwardingLogger,"path\1.0.45\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /t:Package /p:PackageLocation=path /p:platform="x64" /p:configuration="Configuration" /p:VisualStudioVersion="15.0" /m /p:_MSDeployUserAgent="MyTFSAgent"

Am I doing something wrong here?

@DixonDs
Copy link
Author

DixonDs commented Apr 5, 2017

If you don't need to transform web.config in your ASP.NET Core application, a temporary workaround could be to comment out "TransformWebConfig" task and "_TransformWebConfig" target in Microsoft.NET.Sdk.Publish.TransformFiles.targets. Hopefully later there will be a proper resolution of this issue.

@dasMulli
Copy link
Contributor

dasMulli commented Apr 5, 2017

This probably needs to go into the websdk repo https://github.com/aspnet/websdk where those tasks / targets are coming from..
cc @vijayrkn

@DankoValkov
Copy link

While looking through the different .target files I have noticed another issue: _PublishTaskAssemblyFullPath from the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets file is set incorrectly, and that's why the path appears with two backslashes "\" in the error instead with a single backslash "". The fix probably would have to be simple, by removing the extra backslash "" from the following position inside the target file: (26,107). However this is not helping with the issue discussed here.

@vijayrkn
Copy link
Contributor

vijayrkn commented Apr 5, 2017

We just fixed this issue in websdk - dotnet/websdk#174

Work-around:
Change msbuild path from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe to
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe

This issue should only happen when executing the 64 bit version of msbuild. Once the fix is rolled out, it should work for 64 bit as well. Until then, please use the msbuild under Bin\msbuild.exe.

@livarcocc
Copy link
Contributor

Closing since this has been addressed in the web sdk already.

@mtorkamani
Copy link

Hey @vijayrkn,
I'm using VSTS hosted 2017 agent and trying to build my Service Fabric app. I'm getting same error. Any idea?

Thanks

@vijayrkn
Copy link
Contributor

This fix is only available in the 2.0 version of the cli. Can you check what version of dotnet cli is installed on the agent?

@sadiamukhtar
Copy link

sadiamukhtar commented Aug 2, 2017

I have the same issue, where TransformwebConfig could not be loaded due to the error in path "\"
I am using vsts hosted agent as well.
How do I check the dotnet cli version of the hosted 2017 agent on vsts?

Based on https://www.visualstudio.com/en-us/docs/build/concepts/agents/hosted
the hosted agent has a set of available capabilities.

How do I work around this issue when I am using a hosted agent?

Answer:
Under the build solution sfproj task, user MSBuild x86

@night-king
Copy link

C:\Program Files\dotnet\sdk\3.0.100-preview-009812\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): 错误 MSB4018: “TransformWebConfig”任务意外失败。
System.Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to at least AspNetCoreModuleV2.
在 Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.TransformAspNetCore(XElement aspNetCoreElement, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel)
在 Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.Transform(XDocument webConfig, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel, String environmentName)
在 Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
在 Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

@vijayrkn
Copy link
Contributor

@night-king - The log shows that you have an incorrect configuration setup. You cannot have inprocess hosting with AspNetCoreModule.

Can you add this to the csproj? This should fix the issue.

<AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>

@Alienroid
Copy link

I got similar issue as @night-king. "Error MSB4018: The "TransformWebConfig" task failed unexpectedly. System.Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2."

My local builds fine. The issue only happened when I publish to azure.
Steps to resolve my issue:

  1. as @vijayrkn mentioned, add the AspNetCoreModuleV2
  2. save, close project, reopen project
    3) get a new publish profile <--- after this step, publish works and the error went away

GangWang01 pushed a commit to GangWang01/sdk that referenced this issue Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants