是否可以在 VS 代码中使用 monogame? [英] Is it possible to use monogame in VS code?

查看:40
本文介绍了是否可以在 VS 代码中使用 monogame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 iball 笔记本,但我没有足够的内存来安装 Visual Studio.我在使用 VS 代码时没有问题,我能够制作和创建控制台应用程序的可执行文件.我需要学习游戏开发,但每个人都说我需要为它安装visual studio

I am using an iball notebook and I don't have enough memory to install Visual Studio. I am having no problems using VS code and i am able to make and create executables of my console applications. I need to learn game development but everyone keeps saying that i need to install visual studio for it

不过,我确实找到了有关该主题的关于 monogame 的 Fourm,并发现可以(至少在 Linux 上)在 VS 代码中使用 Monogame.

However i did find a fourm on monogame on the topic and found that it is possible(At least on Linux) to use Monogame in VS code.

http://community.monogame.net/t/visual-studio-code-and-monogame/2371

请帮帮我.我想知道是否真的可以在 Windows 中编译和运行单游戏应用程序.

Please Help me out.I want to know if it's really possible to compile and run a monogame app in windows.

推荐答案

答案编辑为 Monogame 发布的官方 dotnet 项目模板

我终于让它工作了.

我意识到我需要的只是创建一个单游戏项目 (*.csproj) 并在没有 Visual Studio 的情况下编译/构建它.VS Code 只是一个功能丰富的文本编辑器,我需要其他工具集.

I realized that all I needed was to create a monogame project (*.csproj) and Compile/Build it without Visual Studio. VS Code is just a feature-rich text editor and I would need other toolset for it.

MSBuild 工具用于编译/构建单游戏项目,可作为 CLI 使用.无需安装 Visual Studio 即可使用.对于 C# 项目构建,需要 dotnet core.执行脚本

MSBuild tool is used to Compile/Build monogame project and is available as a CLI. It is available without installing Visual Studio. For C# project building, dotnet core is required. executing the script

dotnet new [Template]

创建一个新项目.我们需要在这里添加一个monogame的模板.

creates a new Project. We need to add a template for monogame here.

根据 Monogame Team 的最新更新,您可以通过执行来安装模板

As per the latest update by the Monogame Team, you can install the templates by executing

dotnet new --install "MonoGame.Templates.CSharp"

使用脚本

dotnet new -h

查看所有可用的模板.

现在,要生成项目,请使用以下内容

Now, to generate the project, use the following

dotnet new mgwindows

执行成功后会生成[FolderName].csproj、Game1.cs、Program.cs等monogame项目的文件/文件夹.请注意,这个 csproj 是在 .NET Framework 上(如果我没记错的话,是 4.5 版......),因此它可能无法与 dotnet run 命令一起使用.(如果您有点固执,您可能需要将 Monogame 安装文件夹(其中包含许多其他文件,Monogame.target 文件)复制到您的 dotnet 安装文件夹中.)

On successful execution, this will generate [FolderName].csproj, Game1.cs, Program.cs and other files/folders of monogame project. Please not that this csproj is on .NET Framework (version 4.5 if I'm not wrong....) and therefore it might not work with dotnet run command. (If you're a bit stubborn, you might need to copy the Monogame installed folder(which contains, among many other files, Monogame.target file) in your dotnet installed folder.)

也就是说,使用 msbuild 来构建和运行项目

In other words, use msbuild to build and run the project

msbuild

如果程序不包含任何编译时错误,.exe 文件将成功构建,您将看到要执行的输出文件路径.

If the program does not contain any compile time errors, the .exe file will be built successfully and you will get to see the the Output file path which you get to execute.

如果您在 Linux 上工作或有其他原因不使用 MSBuild,则不应生成 mgwindows 项目.你可以选择

If you're working on Linux or have some other reason not to use MSBuild, you should not generate a mgwindows project. You can rather chose

dotnet new desktopgl

适用于 dotnet 核心(即您可以使用 dotnet run 命令来执行它).

which works on dotnet core (i.e you can use dotnet run command to execute it).

这篇关于是否可以在 VS 代码中使用 monogame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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