We copy our production build in a separate folder using post-build events, and replace the app.config
file with our production app.config. However Clickonce reads the files in bin\Release folder.
I have also tried copying all files from our custom build location to bin\Release
folder in the post-build event, but app.config is still overridden (I guess clickonce re-builds the project into bin\Release).
Is it possible to tell Clickonce to read from our custom folder? Or, if that's not the right way to go, how do you handle this kind of situation?
Edit: Additional info
The post-build event script:
del /s /q /f "$(SolutionDir)Build\Client"
rmdir /s /q "$(SolutionDir)Build\Client"
if $(ConfigurationName) == Debug goto :debug
if $(ConfigurationName) == Release goto :release
:release
xcopy "$(TargetDir)*.dll" "$(SolutionDir)Build\Client\Prod\" /Y /I /R
xcopy "$(TargetDir)*MyApp.UI.Win.exe" "$(SolutionDir)Build\Client\Prod\" /Y /I /R
copy "$(TargetDir)Configs\App.Production.config" "$(SolutionDir)Build\Client\Prod\$(TargetFileName).config" /Y
REM for clickonce
copy "$(TargetDir)Configs\App.Production.config" "$(TargetDir)$(TargetFileName).config" /Y
copy "$(TargetDir)Configs\App.Production.config" "$(TargetDir)PostBuildEventWasHere.config" /Y
del /s /q /f "$(TargetDir)\*.pdb"
goto :exit
:debug
xcopy "$(TargetDir)*.dll" "$(SolutionDir)Build\Client\Dev\" /Y /I /R
xcopy "$(TargetDir)*MyApp.UI.Win.exe" "$(SolutionDir)Build\Client\Dev\" /Y /I /R
copy "$(TargetDir)Configs\App.Development.config" "$(SolutionDir)Build\Client\Dev\$(TargetFileName).config" /Y
goto :exit
:exit
And my publish output:
------ Build started: Project: MyApp.UI.Win, Configuration: Release Any CPU ------
(...builds all projects)
Compile complete -- 0 errors, 4 warnings
(...echoing the build event script here, and successful copy/delete messages)
Building MyApp.UI.Win...
(It must be rebuilding here!)
------ Publish started: Project: MyApp.UI.Win, Configuration: Release Any CPU ------
Connecting to '\\MyPublishLocation'...
Publishing files...
Publish success.
\\MyPublishLocation\publish.htm
========== Build: 8 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========