Version 3.2.26 is not copying transforms to output folder (but preview transform works)
soerendalbydk opened this issue · 5 comments
I have used version 3.2.26 to transform an app.config in a Core 3.1 Console project (I use a nuget package that relies on app.config).
I use the nuget package 3.2.26 and the VS Extension.
Preview Transform works fine but the transformed appconfig file is not in the output directory.
I use VS2019
Same for me, since version 3.2.20 (maybe before)
Sometimes it works, but usually it doesn't not sure why. The build folder has the correct output for the App.config but the publish/deploy App.config is always the Debug build option, not my current selected build option..
Exactly the same problem here. Preview transform works perfectly, however the output file is unchanged on build. I have the SlowCheetah extension v3.2.18.443, with the v3.2.26 nuget package. I also tried different versions of the nuget package without success. I'm using VS2019 Community.
Same here
I think the issue is similar to the same issue in FastKoala. See: https://github.com/stimpy77/FastKoala#limitations
Effectively, .NET SDK projects are not fully supported. I did some experiments, and using <Project Sdk="Microsoft.Build.NoTargets/3.0.4" />
results in inability to do Preview Transform or Add Transform. Converting it to <Project Sdk="Microsoft.NET.Sdk" />
results in regaining ability to do Preview Transform and Add Transform, but the file does not actually get transformed on build.
I wonder if there is some <ProjectCapability Include="SlowCheetah"/>
or whatever that needs turning on. So I searched https://github.com/microsoft/slow-cheetah/search?q=IsCapabilityMatch and found
According to the VSProjectSystem readme about_project_capabilities.md, when a capability is expressed with + signs inbetween capabilities, it means its an AND operator
Thus, I was able to do the following insanity and was able to enable Preview Transform (but still can't get Add Transform to work, which may be a clue, but it doesn't actually affect previewing transform if you have the right Content item magic in your xml csproj):
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.Build.NoTargets/3.0.4">
<!-- ReSharper disable UnknownProperty -->
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyTitle>Test</AssemblyTitle>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<BuildPackage>true</BuildPackage>
<PackageVersion>0.0.0.1-dev</PackageVersion>
</PropertyGroup>
<ItemGroup>
<ProjectCapability Include="AssemblyReferences" />
<ProjectCapability Include="DeclaredSourceItems" />
<ProjectCapability Include="UserSourceItems" />
<ProjectCapability Exclude="SharedAssetsProject" />
</ItemGroup>
<PropertyGroup>
<NuspecFile>package.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion);id=$(AssemblyTitle);description=$(AssemblyTitle);authors=$(Company);copyright=$(Copyright)</NuspecProperties>
<NoWarn>NU5100,NU5110,NU5111</NoWarn>
</PropertyGroup>
<PropertyGroup>
<PackDependencies>true</PackDependencies>
</PropertyGroup>
<ItemGroup>
<Content Include="Web.config">
<TransformOnBuild>true</TransformOnBuild>
</Content>
<Content Include="Web.*.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Web.config</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.2.26">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
The Visual Studio Team changed the way that it reacts with files, which is probably the issue that you are running into. Here are some examples of what does work. Your <CopyToOutputDirectory>
element is inside the wrong <Content>
element. You don't want the transform files in your output folder:
Example AppSetting.config
with Debug
, Release
, Debug-Publish
, and Release-Publish
solution configurations:
<ItemGroup>
<Content Update="AppSettings.config">
<TransformOnBuild>true</TransformOnBuild>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="AppSettings.Debug.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>AppSettings.config</DependentUpon>
</None>
<None Include="AppSettings.Debug-Publish.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>AppSettings.config</DependentUpon>
</None>
<None Include="AppSettings.Release.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>AppSettings.config</DependentUpon>
</None>
<None Include="AppSettings.Release-Publish.config">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>AppSettings.config</DependentUpon>
</None>
</ItemGroup>
And here is the <PackageReference>
that you should see:
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.2.26">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>