发布同一 ClickOnce 应用程序的多个版本的最佳方式是什么?

What is the best way to publish multiple versions of the same ClickOnce application?(发布同一 ClickOnce 应用程序的多个版本的最佳方式是什么?)
本文介绍了发布同一 ClickOnce 应用程序的多个版本的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个 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 应用程序的多个版本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

MSBuild cannot find a reference(MSBuild 找不到参考)
The reference assemblies for framework .NETCore, Version=v5.0 were not found(未找到框架 .NETCore,Version=v5.0 的参考程序集)
quot;File has a different computed hash than specified in manifestquot; error when signing the EXE(“文件的计算哈希值与清单中指定的不同签署EXE时出错)
Good-practices: How to reuse .csproj and .sln files to create your MSBuild script for CI?(良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 MSBuild 脚本?)
Run an MSBuild target only if project is actually built(仅在实际构建项目时运行 MSBuild 目标)
MS-Build BeforeBuild not firing(MS-Build BeforeBuild 未触发)