简体   繁体   English

尝试发布自包含时出现 VS Studio 2019 错误

[英]VS Studio 2019 error when trying to publish self-contained

I wrote a c# console application that I want to compile for a linux machine.我写了一个 c# 控制台应用程序,我想为 linux 机器编译它。 When I use the following command in the console, I get this error:当我在控制台中使用以下命令时,我收到此错误:

dotnet publish -r linux-x64 --self-contained true

C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Common.CurrentVersion.targets(3983,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveManifestFiles" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.  Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [X:\Coding\Visual Studio 2019\Projects\firstDiscordBot\firstDiscordBot\firstDiscordBot.csproj]

I read through a lot of similar questions but none of the solutions worked for me.我阅读了很多类似的问题,但没有一个解决方案对我有用。 I tried deleting the.vs folder inside my solution's project folder and did Clean and Build and I tried entering Install-Package MSBuildTasks into the NuGet Package Manager Console and then rebuilding my project.我尝试删除解决方案项目文件夹中的 .vs 文件夹并进行清理和构建,然后尝试将Install-Package MSBuildTasks输入 NuGet Package 管理器控制台,然后重建我的项目。

(Error message in plain text, maybe a bit easier to read:) (纯文本的错误消息,可能更容易阅读:)

C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Common.CurrentVersion.targets(3983,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveManifestFiles" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Common.CurrentVersion.targets(3983,5):错误 MSB4062:无法从 Microsoft 程序集加载“Microsoft.Build.Tasks.ResolveManifestFiles”任务。 Build.Tasks.Core,版本=15.1.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a。 Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.确认声明正确,程序集及其所有依赖项均可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共 class。 [X:\Coding\Visual Studio 2019\Projects\firstDiscordBot\firstDiscordBot\firstDiscordBot.csproj] [X:\Coding\Visual Studio 2019\Projects\firstDiscordBot\firstDiscordBot\firstDiscordBot.csproj]

[Edit] I did some experiments and now the error message says the following: [编辑] 我做了一些实验,现在错误信息如下:

C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Common.CurrentVersion.targets(3975,5): error MSB4062: The "Microsoft.Build.Tasks.SignFile" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Common.CurrentVersion.targets(3975,5):错误 MSB4062:无法从 Microsoft 程序集加载“Microsoft.Build.Tasks.SignFile”任务。 Build.Tasks.Core,版本=15.1.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a。 Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.确认声明正确,程序集及其所有依赖项均可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共 class。 [X:\Coding\Visual Studio 2019\Projects\firstDiscordBot\firstDiscordBot\firstDiscordBot.csproj] [X:\Coding\Visual Studio 2019\Projects\firstDiscordBot\firstDiscordBot\firstDiscordBot.csproj]

I guess the error is basically the same, it probably won't matter much.我猜错误基本上是一样的,它可能并不重要。

I also did some more research and I tried several more things, such as using the 'Publish' feature when right-clicking my project in the Solution-Explorer and reinstalling the SDK.我还做了一些研究并尝试了更多的东西,例如在解决方案资源管理器中右键单击我的项目并重新安装 SDK 时使用“发布”功能。 I also verified all my files several times but none of the above helped.我还多次验证了我的所有文件,但以上都没有帮助。

I just want to mention that every little suggestion would be greatly appreciated as this is the first time, that I don't seem to able to fix the problem, even after multiple hours of research and dedication.我只想提一下,每一个小建议都将不胜感激,因为这是第一次,即使经过多个小时的研究和奉献,我似乎也无法解决问题。 So if there's anything you think I could do, I would be very happy.所以如果有什么你认为我能做的,我会很高兴的。

For anyone with the same issue, I fixed it.对于任何有同样问题的人,我修复了它。 My problem was simply that I was using a .NET-Framework project instead of .NET-Core.我的问题只是我使用的是 .NET-Framework 项目而不是 .NET-Core。 Watch out on that.请注意这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 error NETSDK1031:不支持在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序 - error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier “不支持”在不指定 RuntimeIdentifier 的情况下构建或发布自包含应用程序 - It is “not supported” to build or publish a self-contained application without specifying a RuntimeIdentifier .NET Core 自包含发布引用 - 如何删除未使用的? - .NET Core self-contained publish references - how to remove unused? 在 Windows 中发布便携式和独立的 .NET 应用程序 7 - Publish Portable and Self-Contained .NET Application in Windows 7 dotnet publish --Linux 容器上的自包含选项 - dotnet publish --self-contained option on Linux container 单元测试:自包含测试与代码重复(DRY) - Unit Testing: Self-contained tests vs code duplication (DRY) .Net core 3.1 worker 服务自包含发布在 vs 2019 中失败 - .Net core 3.1 worker service self contained publish failed in vs 2019 独立的普通纪念品 - Self-contained generic memento 尝试在 Visual Studio (2019) 中发布时复制文件失败 - Failed to copy file when trying to publish in Visual Studio (2019) 如何发布引用另一个可执行文件的独立 C# 可执行文件? - How to publish a self-contained C# executable that references another executable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM