Search code examples
c#application-settingspost-build-event

.NET Build events xcopy application settings.settings


I am trying to add these lines to the application's Build Events

xcopy debug.settings settings.settings

In order to acees the debug.settings as Default, but I am getting a exited with code 4 error when compiling. I have read code 4 would probably mean that it cannot find the specified files. But how would I reference debug.settings?

I have this file as part of my application's properties:

enter image description here

I got this idea from a stackoverflow question: .NET different application settings for development and release This would be a followup question based on its answer.


Solution

  • This is likely because xcopy cannot find the source and destination paths for the settings files. Try updating them to the fully qualified path (i.e. C:\SomeFolder\MyProject\debug.settings).

    Also, check out the documentation when in doubt (or looking for what error codes mean).

    As an aside, if you are simply looking for a way to change values in an app.config or web.config based on your build configuration, take a look at SlowCheetah.