slow-cheetah
slow-cheetah copied to clipboard
Slowcheetah in a web project (.NET Core 3.0 SDK): The "TransformXml" task failes
Hi, we are using Slowcheetah in an ASP.NET Core 2.1 web project. When building the project with a .NET Core 2.1 SDK everything works fine. But when building the project with .NET Core 3.0 SDK (3.0.100) we get an error:
C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(101,5): error MSB4018: The "TransformXml" task failed unexpectedly. C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(101,5): error MSB4018: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=3.0.0.34420, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not find or load a specific file. (0x80131621)
Any ideas?
Thanks!
Hi. I got same issue with setup like this: MyService.sln:
-
MyService/MyService.csproj
(asp .net core 3.1)- web.config
- web.Debug.config
- web.Release.config
-
MyService.Configuration/MyService.Configuration.csproj
(.net standard 2)- settings.json
- settings.Debug.json
- settings.Release.json
XMLTransform failed unexpectedly during the publish.
Solution: keep all transformable configuration in projects of same kind. E.g. in my case I moved web.config under Configuration project.
Cause: based on error and random failures in xmltransform (it worked occasionally) I assume dotnet cli tries to load two different version of slowcheetah (one .net core specific and one .net standard specific) which are not compatible and fails with error complaining about not being able to load version 3. (Not sure what is the version of the other one)
Noticing this on my CI server after installing dotnet core 3.0 SDK -- my netcoreapp2.1 project started seeing failures on publish with the 3.0.100 dotnet
CLI tools.
Edit: for anyone else in this situation, my fix was pegging the 2.1 SDK version via a global.json file using the following command:
dotnet new globaljson --sdk-version 2.1.803
This fixes the transform issue for me noted above by @Tobias-Gr
Frustrating to not be able to track down why it can't find the Microsoft.Web.XmlTransform assembly using 3.x SDK tools. Any guidance for a better solution would be greatly appreciated.
Edit 2: BTW, the global JSON does not support wildcarding so be prepared to ensure your environments (local & CI server for me) are on exactly the same featureband/patch version.
I stumbled upon the same issue and tried to reproduce it starting with dotnet new web
, adding the SlowCheetah dependency etc.
In my case I had some <TransformOnBuild>true</TransformOnBuild>
elements in my project file, and the issue was solved by removing them (commented out here)
<Content Update="appsettings.json">
<!-- <TransformOnBuild>true</TransformOnBuild> -->
</Content>
PS. I have a custom target to do all transforms for all environments in one go by explicitly calling <SlowCheetah.TransformTask Source=... Transform=... Destination=...>
so I do not rely on the automatic SlowCheetah transforms at build time.
Did have the same error when moving from our .net core 2.2 app to .net core 3.1
The cause was the Slowcheetah nuget package installed. After some reflection and search in the docs, I found out that, in our case, SlowCheetah wasn't needed anymore. In the past we did have an app.config file and we used SlowCheetah to do the transformations, but today we don't have an app.config anymore.
The appsettings.json file and his specific .net core environments versions are loaded directly by .net core 3 by the WebHost.CreateDefaultBuilder in the Program.cs file. Never needed SlowCheetah here.
The web.config file and his specific environment files are now also transformed for .net core like in the full .NET days by Visual Studio itselfs.
So, deinstalled the nuget SlowCheetah package and as result no build errors anymore about not finding his "TransformXml" task...
Having a similar issue I think, but I do not understand the comments by @ericvb and only partially understand the proposed solution by @Cpcrook. So we need to set the global json in the solution? Please advise. Thanks... Annoying as heck that such an ordinary thing to want to do as transform JSON, in our case, is blocked by this thing.
Which for me the problem persists MSB4018
:
Severity Code Description Project File Line Suppression State
Error MSB4018 The "SlowCheetah.TransformTask" task failed unexpectedly.
System.IO.FileNotFoundException: File not found
File name: 'path\to\aggregate-cleaning-uw\MyApp\appsettings.json;path\to\aggregate-cleaning-uw\MyApp\appsettings.json'
at Microsoft.VisualStudio.SlowCheetah.JsonTransformer.IsFileSupported(String filePath)
at Microsoft.VisualStudio.SlowCheetah.TransformerFactory.<>c__DisplayClass1_0.<GetTransformer>b__0(ITransformer tr)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Microsoft.VisualStudio.SlowCheetah.TransformerFactory.GetTransformer(String source, ITransformationLogger logger)
at Microsoft.VisualStudio.SlowCheetah.TransformTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() MyApp path\to\aggregate-cleaning-uw\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets 115
@mwpowellhtx Do you have an app.config file that you must transform? If not and you have only appsettings.json and web.config files in your projects, uninstall the SlowCheetah nuget package. You don't need it anymore in VS2019 with .net core 3.x
@ericvb I got it working, I think. Not sure in what version there is a JSON transformation dependency, but some of the latest transformation protocols apparently do not work, or maybe the dependency is out dated. With the source being this:
{
"DatabaseSettings": {
"ConnectionString": "..."
}
}
This seems to work:
{
"DatabaseSettings": {
/* Note, just this, no need for other @jdt hooks, AFAIK... */
"@jdt.replace": {
/* ^^^^^^^^^^^^^^ */
"ConnectionString": "..."
}
}
}