slow-cheetah
slow-cheetah copied to clipboard
Transform config files and nothing else
We have successfully transformed our app.config
and web.config
files. However, for some reason we sometimes get errors on files where we did not expect the transformer to run. E.g. one of our png
files (marked as Resource
) gave us this error:
The item "foo.png" in item list "Resource" does not define a value for metadata "TransformOnBuild". In order to use this metadata, either qualify it by specifying %(Resource.TransformOnBuild), or ensure that all items in this list define a value for this metadata.
We want to transform config files and nothing else. How can we force this behavior?
We did see that adding the Nuget package added some suspicious targets in the project file:
<Import Project="..\..\..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets"
Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
Not sure if that has anything to do with it?
when I used a lower case first letter to the file name, the Add Transform item appeared in the short cut menu. In other words, App.config did not display Add Transform, but when I renamed to app.config, the Add Transform displayed in the shortcut menu when I right clicked on the file name.
I'm having the exact same issue here. Did you find a solution for this problem?
_"We have successfully transformed our app.config and web.config files. However, for some reason we sometimes get errors on files where we did not expect the transformer to run. E.g. one of our png files (marked as Resource) gave us this error:"_
Nope 🙁
Could this be caused by creating entries in the Resource items group, by Including them from another group.
This means the ItemDefinition that defines <TransformOnBuild>false</TransformOnBuild>
does not apply (it copies the ItemDefinition from the source group, not the target group).
You might be able to get past this by setting that metadata manually where you copy in the group.
e.g.
<Resource Include="@(MyImageFiles)">
<TransformOnBuild>false</TransformOnBuild>
</Resource>
I don't know if you have some other MSBuild targets, maybe like an image optimizer, that generates Resource items?
This was happening to me on a png file. I changed the Build Action on the Properties of the file from Resource to None and was able to build the project. I then changed the Build Action back to Resource and again it was able to build. I just recently switched to using Visual Studio 2022 and this started happening but like I said changing the Build Action then changing it right back did the trick.