microsoft/slow-cheetah

Transforming appsettings.json failing under VS2019

mwpowellhtx opened this issue · 2 comments

I get the following exception during build transforming a Json based connection string:

1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018: The "SlowCheetah.TransformTask" task failed unexpectedly.
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018: System.IO.FileNotFoundException: File not found
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018: File name: 'path\to\MyApp\appsettings.json;path\to\MyApp\appsettings.json'
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.VisualStudio.SlowCheetah.JsonTransformer.IsFileSupported(String filePath)
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.VisualStudio.SlowCheetah.TransformerFactory.<>c__DisplayClass1_0.<GetTransformer>b__0(ITransformer tr)
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.VisualStudio.SlowCheetah.TransformerFactory.GetTransformer(String source, ITransformationLogger logger)
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.VisualStudio.SlowCheetah.TransformTask.Execute()
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>path\to\packages\microsoft.visualstudio.slowcheetah\3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets(115,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

The source appsettings.json is:

{
    "DatabaseSettings": {
        "ConnectionString": "..."
    }
}

And I want to replace the connection string, correct, such as, appsettings.Debug.json:

{
    "DatabaseSettings": {
        "@jdt.replace": {
            "@jdt.path": "$.ConnectionString",
            "@jdt.value": "..."
        }
    }
}

Also, was not being invoked by default, so I had to do something like this in my project file:

<ItemGroup>
    <None Remove="appsettings.*.json" />
    <None Include="appsettings.json">
        <TransformOnBuild>true</TransformOnBuild>
    </None>
    <None Include="appsettings.Debug.json">
        <DependentUpon>appsettings.json</DependentUpon>
        <IsTransformFile>True</IsTransformFile>
    </None>
    <None Include="appsettings.Release.json">
        <DependentUpon>appsettings.json</DependentUpon>
        <IsTransformFile>True</IsTransformFile>
    </None>
</ItemGroup>

Am I doing something wrong?

I might also add, if I right click the transformation files, I do not get a Preview Transformation, but rather Add Transformation which leads me to believe something isn't quite right.

I got it sorted out, I think.