问题描述
所以我想简单地用C#在Visual Studio 2019中新建一个Monogame项目,每次新建项目时,都会出现如下错误:
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
项目中唯一的文件是作为 Monogame 跨平台模板的一部分自动创建的文件。
我已经查看了 Google 和 Stack Overflow,虽然有答案,但我没有找到任何对我有帮助的。
抱歉,如果我在创建帖子时搞砸了,这是我的第一个 Stack Overflow 问题:D 我可能在某处搞乱了格式,所以如果我有的话,请提前抱歉。
解决方法
使用终端创建项目(然后在 Visual Studio 中打开它们)是更好的方法。 Monogame 社区发布项目的 NuGet 模板比发布 Visual Studio 插件要方便得多,因此可以安全地假设 Monogame 不会很快为 Visual Studio 发布此类插件。
确保您已安装 dotnet-sdk
并通过执行 here 中提到的所有步骤(包括最后两个脚本)安装 Monogame 工具
dotnet tool install --global dotnet-mgcb-editor
mgcb-editor --register
和
dotnet new --install MonoGame.Templates.CSharp
现在使用命令 dotnet new
查看所有模板。您可能会看到诸如
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
...
...
选择你要创建的项目,例如
dotnet new mgwindowsdx -o MyGame
这将创建一个文件夹“MyGame”并放置您的游戏代码。您可以使用 Visual Studio 打开 .csproj
文件。