天天看點

clickonce 部署能cs程式,釋出同一ClickOnce應用程式的多個版本的最佳方法是什麼?...

clickonce 部署能cs程式,釋出同一ClickOnce應用程式的多個版本的最佳方法是什麼?...

I have a c# ClickOnce application that I need to be able to publish multiple times for OEM purposes.

The way I understand it now is that publish settings are located in the .csproj file.

However, this is inconvenient in the case where I want to publish multiple versions.

for example, Company A needs totally different icons, start menu location, product name etc. from Company B, but the assemblies need not be renamed.

Here are a couple approaches/questions that I can think of to solve this issue...

1.Is there a way to create a separate publish settings file to use during build time?

2.Can I edit specific publish settings (like Start Menu location, etc) at build time with MSBuild.exe? I think this would be ideal...

e.g.

MSBuild.exe project.sln /target:Publish /property:edit-project-publish-settings-here

3.Maybe create a 2nd .csproj file? (Would prefer not to do this...)

Please share your thoughts as to the best approach, or any other clever ways to make this happen. Thanks!

解決方案

If you copy the .csproj in your project folder, it will reference all of the same source files and you can just change the executable name. Create another VS solution and you can reference the copied .csproj and get rid of your first one so that you can publish two separate versions.

This isn't ideal for ClickOnce however.

If you use a Singleton object that specifies the "mode" (Company A, B, C, etc.) you can easily store that in the app.config (or another xml file). Then just re-publish your ClickOnce Application but copy the correct version of your configuration file in so it gets shipped with the build. This way, you don't need any additional csprojects Just include all of your icons and set them at run-time on App Start based on your Singleton object.