当文件位于它们必须位于的位置时,ClickOnce 无法找到其先决条件

ClickOnce cannot find its prerequisites while the files are at the place they have to be

我想使用 ClickOnce with some prerequisites (.NET 4.5 and SQL Server Express).

发布我的应用程序

我按照 How to: Include Prerequisites with a ClickOnce Application (note that the package folders were at v8.1A folder instead of v8A folder), but it still says it can't find the files. I've tried both Visual Studio 2013 and Visual Studio 2015 RC 中的说明做了。

To enable 'Download prerequisites from the same location as my application' in the Prerequisites dialog box, you must download file 'DotNetFX45\dotNetFx45_Full_x86_x64.exe' for item 'Microsoft .NET Framework 4.5 (x86 and x64)' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=239883.

To enable 'Download prerequisites from the same location as my application' in the Prerequisites dialog box, you must download file 'SqlExpress2012\SQLEXPR32_x86_ENU.EXE' for item 'SQL Server 2012 Express' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=239883.

To enable 'Download prerequisites from the same location as my application' in the Prerequisites dialog box, you must download file 'SqlExpress2012\SQLEXPR_x64_ENU.EXE' for item 'SQL Server 2012 Express' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=239883.

To enable 'Download prerequisites from the same location as my application' in the Prerequisites dialog box, you must download file 'DotNetFX40ClientKB2468871\dotNetFx40_Client_x86_x64.exe' for item 'Microsoft .NET Framework 4 Client Profile (x86 and x64) and Update for .NET Framework 4 (KB2468871)' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=239883.

我过去完成这种情况的方法只是使用内置的 "publish" 功能。根据我的经验,它们似乎运作良好。

在应用程序的“发布配置”部分,有一个 "Prerequisites" 按钮,您可以单击该按钮并选中 .NET Framework 和 SQL Express 等。在 ClickOnce 安装过程中,它会提示用户在安装您的应用程序之前从 Microsoft 下载它们。

您对 ClickOnce 部署中的可能性有一个非常错误的想法。规范的 MSDN 页面是 this one。突出显示该网页中最重要的部分:

Impact to the user's computer. With Windows Installer deployment, applications often rely on shared components, with the potential for versioning conflicts; with ClickOnce deployment, each application is self-contained and cannot interfere with other applications.
Security permissions. Windows Installer deployment requires administrative permissions and allows only limited user installation; ClickOnce deployment enables non-administrative users to install and grants only those Code Access Security permissions necessary for the application.

Does not affect shared components or other applications: Yes
Installation of shared files: No
Installation to Global Assembly Cache: No
Installation for multiple users: No
Install time registry access: Limited

这些有意的限制旨在让用户对使用 ClickOnce 安装 .NET 程序感觉良好。他们不需要管理员的帮助来安装程序。并且安装程序不能对机器进行大刀阔斧的改动,这种改动会导致其他程序出现故障。安装程序的一个非常非常普遍的问题。

这与您正在尝试做的事情完全不相容。 .NET Framework 和 SQL Express 都是 共享组件,并且 do 需要管理员权限才能安装和 do 风险破坏已经安装了 .NET 或 SQL 服务器的机器。

所以这根本行不通。您 可以 select 它们作为先决条件,但在安装时发生的所有事情都是 ClickOnce 安装程序验证它们是否满足。换句话说,机器必须已经安装了正确版本的 .NET 和 SQL Express。如果没有,则部署将失败,用户会看到一个对话框,告诉他在哪里下载安装程序。然后完全由他(或他的管理员)下载和 运行 安装程序。之后您的 ClickOnce 安装将顺利完成。

部署向导相当简陋,应该把单选按钮隐藏在底部。对于这些先决条件,只有 "from the component vendor's web site" 是有效的 selection。引导程序 .xml 文件格式不够复杂,无法限制 selection.

如果您想为用户提供安装程序附带的这些先决条件,唯一的方法是创建一个普通的 MSI 安装程序。