如何在Visual Studio安装程序项目中打包.NET Core 3 [英] How to package .NET Core 3 in Visual Studio Installer Project

查看:504
本文介绍了如何在Visual Studio安装程序项目中打包.NET Core 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我想为基于.NET Core 3的C#项目创建安装程序.我安装了Visual Studio 2019的Installer Projects扩展,并在解决方案中创建了一个新的Installer项目.在尝试了不同的设置之后,我最终将我的两个可执行文件的PublishItemsOutputGroup添加到应用程序文件夹中. 这(向重复的dll抛出各种警告)会创建一个不错的安装程序包,其中应该"包含所有必需的dll(.net库很多).但是,在目标计算机上执行一个已安装的exe文件之一后,我得到了:

So, I want to create an installer for my .NET Core 3 based C# project. I installed the Installer Projects extension for Visual Studio 2019 and created a new Installer project within my solution. After some trying around with different settings, I ended up with adding PublishItemsOutputGroup for my two executables to the Application Folder. This (throwing various warnings for duplicate dlls) creates a nice installer package with "supposedly" all required dlls (there are quite a lot of .net libs). However, upon executing one of the installed exe files on a target computer, I am getting:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet
  - Installing .NET Core prerequisites might help resolve this problem:
      https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.2.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

我知道,发布.exe文件时可以创建一个巨大的自包含.exe,但是,这对我来说似乎很浪费-创建两个包含几乎相同的.dll的巨大.exe文件.

I know, I could create a gigantic self-contained .exe when publishing the .exe files, however, that seems kind of wasteful to me - creating two gigantic .exe files that contain mostly the same .dlls anyways.

是否也没有办法在安装程序项目中包括.NET Core 3安装程序?我在互联网上找不到关于该主题的任何东西...

Is there no way to include a .NET Core 3 setup in the installer project as well? I can't find anything on that topic on the internet...

推荐答案

对于我来说,在收集依赖项时,用PublishItemsOutputGroup替换PrimaryOutput可以很好地工作. 不幸的是,它不允许在安装程序中引用这些输出.例如.如果要在安装过程中运行自定义操作或创建快捷方式,则此操作将无效.输出不可用.

For me replacing PrimaryOutput with PublishItemsOutputGroup works fine, when it comes to gathering the dependencies. Unfortunately it does not allow referencing those outputs inside the installer. E.g. if you want to run custom actions or create Shortcuts during the installation, it does not work. The outputs are not available.

这篇关于如何在Visual Studio安装程序项目中打包.NET Core 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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