app,config not overwritten or changes not picked up with custom app.config files according to Build cofiguration

StackOverflow https://stackoverflow.com/questions/16511128

Domanda

I am currently creating a solution that must both work with localdb and sqlservercompact 4.0, using EntityFramework Code First. I created therefor extra builconfigurations: LocalDb and SQLCE. Obviously I need different app.config files for these build configurations. I found this excellent solution and used its second option: changing the MSBuild behaviour by using an AfterBuild directive. So I included the XML below in the WPF-application's project file:

<Target Name="AfterBuild">
    <Delete Files="$(TargetDir)$(TargetFileName).config" />
    <Copy SourceFiles="$(ProjectDir)\Config\App.$(Configuration).config" DestinationFiles="$(TargetDir)$(TargetFileName).config" />
  </Target>

This works beautifully on my Win8 development laptop at home, but it seems that the directive is ignored on my Win7 desktop at work. I noticed that where my class.dll's have commented out templates to add PreBuild and AfterBuild directives, the WPF-application did not have it. I checked the Build screen to see if the directive was executed and it was. Seemingly the change is not picked up or overwritten once more. What is happening?

È stato utile?

Soluzione

Never mind: the solution above was for class libraries, for instance for unit test projects. For desktop applications you do need Slow Cheetah. Works like a charm.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top