在 Visual Studio 2019 中创建 Monogame C# 项目时出现错误 MSB3073 [英] Error MSB3073 when creating a Monogame C# project in Visual Studio 2019

查看:135
本文介绍了在 Visual Studio 2019 中创建 Monogame C# 项目时出现错误 MSB3073的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想简单地用C#在Visual Studio 2019中新建一个Monogame项目,每次新建项目时,都会出现如下错误:

错误 MSB3073 - 命令"dotnet C:\Users\Jack Bennett\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll/quiet/@:E:\Programming\Locally-stored projects\C Family\C#\Monogame -OxygOS\Game1\Game1\Content\Content.mgcb"/platform:DesktopGL/outputDir:E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/bin/DesktopGL/Content"/intermediateDir:E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/obj/DesktopGL/Content"/workingDir:"E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/""退出代码 1.Game1 C:\Users\Jack Bennett\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets 138

项目中唯一的文件是作为 Monogame 跨平台模板的一部分自动创建的文件.

我已经查看了 Google 和 Stack Overflow,虽然有答案,但我没有找到任何对我有帮助的.

抱歉,如果我在创建帖子时搞砸了,这是我的第一个 Stack Overflow 问题:D 我可能在某处搞乱了格式,所以如果我有的话,请提前抱歉.

解决方案

使用终端创建项目(然后在 Visual Studio 中打开它们)是更好的方法.Monogame 社区发布项目的 NuGet 模板比发布 Visual Studio 插件要方便得多,因此可以安全地假设 Monogame 不会很快为 Visual Studio 发布此类插件.

确保您已安装 dotnet-sdk 并通过执行上述所有步骤安装 Monogame 工具 这里,包括最后两个脚本

dotnet 工具安装 --global dotnet-mgcb-editormgcb-editor --register

dotnet new --install MonoGame.Templates.CSharp

现在使用命令 dotnet new 查看所有模板.您可能会看到诸如

之类的输出<预><代码>模板短名称语言标签------------------------------------------------------ -------------------- ------------ ----------------------......MonoGame Android 应用程序 mgandroid [C#] MonoGameMonoGame 跨平台桌面应用程序 (OpenGL) mgdesktopgl [C#] MonoGameMonoGame iPhone/iPad 应用程序 mgios [C#] MonoGameMonoGame Windows 通用应用程序 (CoreApp) mguwpcore [C#] MonoGameMonoGame Windows 通用应用程序 (XAML) mguwpxaml [C#] MonoGameMonoGame Windows 桌面应用程序 (Windows DirectX) mgwindowsdx [C#] MonoGameMonoGame NetStandard 库 mgnetstandard [C#] MonoGameMonoGame 管道扩展 mgpipeline [C#] MonoGameMonoGame 共享库项目 mgshared [C#] MonoGame......

选择你要创建的项目,例如

dotnet new mgwindowsdx -o MyGame

这将创建一个文件夹MyGame".并输入您的游戏代码.您可以使用 Visual Studio 打开 .csproj 文件.

So I'm trying to simply create a new Monogame project in Visual Studio 2019 with C#, and every time I create a new project, the following error appears:

Error MSB3073 - The command 
"dotnet C:\Users\Jack Bennett\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"E:\Programming\Locally-stored projects\C Family\C#\Monogame -OxygOS\Game1\Game1\Content\Content.mgcb" /platform:DesktopGL /outputDir:"E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/bin/DesktopGL/Content" /intermediateDir:"E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/obj/DesktopGL/Content" /workingDir:"E:/Programming/Locally-stored projects/C Family/C#/Monogame - OxygOS/Game1/Game1/Content/"" exited with code 1.   Game1   C:\Users\Jack Bennett\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets  138 

The only files in the projects are ones that are automatically created as part of the Monogame Cross-platform template.

I've already looked on Google and Stack Overflow, and, while there are answers, I haven't found any that have helped me.

Apologies if I messed up while creating the post, this is my first Stack Overflow question :D I may have messed up the formatting somewhere so sorry in advance if I have.

解决方案

It is a better approach that you would use the terminal to create your project (and then open them in Visual Studio). It is far more convenient for the Monogame community to release NuGet templates of the projects rather than releasing plugins for Visual Studio, and therefore it is safe to assume that Monogame won't be releasing such plugins for Visual Studio anytime soon.

Make sure you have dotnet-sdk installed and the Monogame tools are installed by doing all the steps mentioned here, Including the last two scripts

dotnet tool install --global dotnet-mgcb-editor
mgcb-editor --register

and

dotnet new --install MonoGame.Templates.CSharp

Now use the command dotnet new to view all the templates. You will probably see an output such as


Templates                                                   Short Name               Language          Tags
------------------------------------------------------      -------------------      ------------      ----------------------
...
...
MonoGame Android Application                                mgandroid                [C#]              MonoGame
MonoGame Cross-Platform Desktop Application (OpenGL)        mgdesktopgl              [C#]              MonoGame
MonoGame iPhone/iPad Application                            mgios                    [C#]              MonoGame
MonoGame Windows Universal Application (CoreApp)            mguwpcore                [C#]              MonoGame
MonoGame Windows Universal Application (XAML)               mguwpxaml                [C#]              MonoGame
MonoGame Windows Desktop Application (Windows DirectX)      mgwindowsdx              [C#]              MonoGame
MonoGame NetStandard Library                                mgnetstandard            [C#]              MonoGame
MonoGame Pipeline Extension                                 mgpipeline               [C#]              MonoGame
MonoGame Shared Library Project                             mgshared                 [C#]              MonoGame
...
...

Select the project you want to create, for example

dotnet new mgwindowsdx -o MyGame

This will create a folder "MyGame" and put the code for your game. You can open the .csproj file using Visual Studio.

这篇关于在 Visual Studio 2019 中创建 Monogame C# 项目时出现错误 MSB3073的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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