我有一个 c# ClickOnce 应用程序,我需要能够为 OEM 目的多次发布.
I have a c# ClickOnce application that I need to be able to publish multiple times for OEM purposes.
我现在理解的方式是发布设置位于 .csproj 文件中.但是,在我想发布多个版本的情况下,这很不方便.
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.
例如,A 公司需要与 B 公司完全不同的图标、开始菜单位置、产品名称等,但程序集不需要重命名.
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.有没有办法创建一个单独的发布设置文件以在构建时使用?
1.Is there a way to create a separate publish settings file to use during build time?
2.我可以在构建时使用 MSBuild.exe 编辑特定的发布设置(如开始菜单位置等)吗?我认为这将是理想的...例如
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
MSBuild.exe project.sln /target:Publish /property:edit-project-publish-settings-here
3.也许创建第二个 .csproj 文件?(不想这样做……)
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!
如果您将 .csproj 复制到项目文件夹中,它将引用所有相同的源文件,您只需更改可执行文件名称即可.创建另一个 VS 解决方案,您可以引用复制的 .csproj 并摆脱第一个,以便发布两个单独的版本.
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.
然而,这对于 ClickOnce 来说并不理想.
This isn't ideal for ClickOnce however.
如果您使用指定模式"(公司 A、B、C 等)的 Singleton 对象,您可以轻松地将其存储在 app.config(或其他 xml 文件)中.然后只需重新发布您的 ClickOnce 应用程序,但复制正确版本的配置文件,以便它与构建一起提供.这样,您不需要任何额外的 csprojects 只需包含所有图标并在运行时根据您的 Singleton 对象在 App Start 上设置它们.
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.
这篇关于发布同一 ClickOnce 应用程序的多个版本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!