部署无需安装即可运行的 Visual Studio 应用程序的最佳方式 [英] Best way to deploy Visual Studio application that can run without installing

查看:21
本文介绍了部署无需安装即可运行的 Visual Studio 应用程序的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 C#/.NET 编写了一个相当简单的应用程序,但找不到发布它的好方法.这是一种工具"用户只会运行一次,或者每隔几个月运行一次.因此,我希望有一种方法可以将它部署到不需要安装即可运行的地方(只需在下载后直接双击 EXE 文件即可运行).

I wrote a fairly simple application with C#/.NET and can't figure out a good way to publish it. It's a sort of a "tool" that users would only run once, or run every few months. Because of this, I'm hoping that there is a way I could deploy it where it wouldn't need installing to run (it could just be run by double-clicking an EXE file straight after downloading).

但是,它仍然需要(以某种方式)包含正确版本的 .NET、库等,以便正确运行.我知道这在使用 ClickOnce 时包含在内,但仍会将应用程序安装到用户的计算机上.

However, it still needs (somehow) to include the correct version of .NET, libraries, etc. so it will run correctly. I know this is included when using ClickOnce, but that still installs the application onto the user's computer.

有没有办法做到这一点?

Is there a way this can be done?

编辑 - inDebug

EDIT - inDebug

myAppName.application
myAppName.exe
myAppName.exe.config
myAppName.exe.manifest
myAppName.pdb
myAppName.vshost.application
myAppName.vshost.exe
myAppName.vshost.exe.config
myAppName.vshost.exe.manifest
extraLibrary.dll

还有两个文件夹

app.publish
Resources

推荐答案

这是可能的,而且看似简单:

It is possible and is deceptively easy:

  1. 发布"应用程序(例如,驱动器 C 上的某个文件夹),可以从菜单 Build 或从项目的属性 → Publish.这将为 ClickOnce 应用程序创建安装程序.
  2. 但是不是使用生成的安装程序,而是找到生成的文件(EXE 文件和 .config.manifest.application 文件,以及任何 DLL 文件等) - 它们都在同一个文件夹中,通常位于项目文件(.csproj).
  3. 压缩该文件夹(省略任何 *.vhost.* 文件和 app.publish 文件夹(不需要它们)和 .pdb 文件,除非您预见直接在您用户的系统上进行调试(例如,通过远程控制)),并将其提供给用户.
  1. "Publish" the application (to, say, some folder on drive C), either from menu Build or from the project's properties → Publish. This will create an installer for a ClickOnce application.
  2. But instead of using the produced installer, find the produced files (the EXE file and the .config, .manifest, and .application files, along with any DLL files, etc.) - they are all in the same folder and typically in the binDebug folder below the project file (.csproj).
  3. Zip that folder (leave out any *.vhost.* files and the app.publish folder (they are not needed), and the .pdb files unless you foresee debugging directly on your user's system (for example, by remote control)), and provide it to the users.

另外一个优点是,作为 ClickOnce 应用程序,它不需要管理权限即可运行(如果您的应用程序遵循用于应用程序数据的文件夹等的正常准则).

An added advantage is that, as a ClickOnce application, it does not require administrative privileges to run (if your application follows the normal guidelines for which folders to use for application data, etc.).

至于 .NET,您可以检查应用程序中安装(或根本安装)所需的最低 .NET 版本(大多数用户已经安装),并显示一个对话框,其中包含指向下载页面的链接Microsoft 网站(或指向可以重定向到 Microsoft 页面的页面之一 - 如果 Microsoft URL 更改,这会使其更加强大).由于它是一个小型实用程序,您可以针对 .NET 2.0 来降低用户安装 .NET 的可能性.

As for .NET, you can check for the minimum required version of .NET being installed (or at all) in the application (most users will already have it installed) and present a dialog with a link to the download page on the Microsoft website (or point to one of your pages that could redirect to the Microsoft page - this makes it more robust if the Microsoft URL change). As it is a small utility, you could target .NET 2.0 to reduce a user's probability to install .NET.

它有效.我们在开发和测试期间使用这种方法,以避免不断卸载和安装应用程序,并且仍然非常接近最终应用程序的运行方式.

It works. We use this method during development and test to avoid constantly uninstalling and installing the application and still being quite close to how the final application will run.

这篇关于部署无需安装即可运行的 Visual Studio 应用程序的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆