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

.NET 4.5 MSBuild Transforms not working #71

Closed
johnmurphy01 opened this issue Aug 10, 2017 · 5 comments
Closed

.NET 4.5 MSBuild Transforms not working #71

johnmurphy01 opened this issue Aug 10, 2017 · 5 comments

Comments

@johnmurphy01
Copy link

I have version 3.0.61 installed via Nuget.

My project is a .NET 4.5 Console Application(using Visual Studio 2015) and I want to transform my App.config file. I have created the transforms

image

In the .csproj file, I see that the markup necessary to get SlowCheetah to work is present(although there are warnings about invalid child elements for TransformOnBuild and IsTransformFile:

image

I see that the target for SlowCheetah is referenced:

image

But, when I build my project, for example in Release configuration, my transforms were not applied. In the output window, I do not see any reference to the fact that SlowCheetah is even trying to run, making me think that the Tasks are just not running and/or aren't being referenced.

Ultimately, I want to be able to run MSBuild during my Continuous Integration process and have the transforms apply appropriately.

@jviau
Copy link
Member

jviau commented Aug 14, 2017

You can ignore the xml warnings - Visual Studio editor has an xsd for msbuild, but it only contains a limited set of items. MSBuild xml ultimately has no defined schema for properties and item metadata.

I believe the issue is slow-cheetah is running, but app.config is then being copied to the output directory and undoing the transform. Can you remove this line and try again:

<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

@johnmurphy01
Copy link
Author

I removed the above line but now there is no App.config at all in my Release folder. In Visual Studio, the Copy to Output Directory option is now set to Do not copy

@johnmurphy01
Copy link
Author

Ok, more info. I turned on Detailed verbosity for MSBuild.

The App.config file is successfully transformed into obj\Release\MyProject.csproj-sc.App.config

However, further down, the -sc.App.config file is then copied into bin\Release\MyProject.exe.config. I am guessing that having an App.config and the MyPrjoect.exe.config was causing problems? Possibly the application was reading the App.config file instead of the MyProject.exe.config file? I'm not super familiar with the whole app.config ecosystem, so this is just a speculation.

@johnmurphy01
Copy link
Author

I believe this can be closed now, the issue I think was as @jviau pointed out and the app was looking at the copied App.config and not the transformed .exe.config file.

@jviau
Copy link
Member

jviau commented Aug 15, 2017

@johnmurphy01 sorry, I completely missed that this was an app.config file. You are correct, app.configs are transformed to .exe.config or .dll.config. Maybe having a separate app.config does cause confusion? I am not sure about that though, never tried it myself.

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

2 participants