https://www.reddit.com/r/monogame/comments/cst49i/the_ultimate_guide_to_getting_started_with/
Download and install the latest versions of the following:
-
Visual Studio Code
-
MonoGame for Visual Studio (we only need the pipeline tool)
-
.NET Core SDK
NOTE: You only need to run the following commands once.
Install NUnit templates for writing unit tests:
dotnet new -i NUnit3.DotNetNew.Template
Install MonoGame project templates.
dotnet new -i MonoGame.Template.CSharp
dotnet restore
dotnet new sln
dotnet new mgdesktopgl -o <MyProject>
dotnet sln add <MyProject>/<MyProject>.csproj
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!-- Set to "netcoreapp" plus the first 2 digits of your .NET Core SDK version. -->
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<ItemGroup>
<MonoGameContentReference Include="**\*.mgcb" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.4" />
<PackageReference Include="MonoGame.Framework.DesktopGL.Core" Version="3.7.0.7" />
</ItemGroup>
<!-- Actually cleans your project when you run "dotnet clean" -->
<Target Name="SpicNSpan" AfterTargets="Clean">
<!-- Remove obj folder -->
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<!-- Remove bin folder -->
<RemoveDir Directories="$(BaseOutputPath)" />
</Target>
└── <MyProject>
├── <MyProject>.sln
├── <MyProject>
| └── <MyProject>.csproj
└── <MyProject>.Tests
cd ./<Myproject>.Tests
dotnet new nunit
dotnet add reference ../<MyProject>/<MyProject>.csproj
cd ..
dotnet sln add ./<MyProject>.Tests/<MyProject>.Tests.csproj
Change the TargetFrameWork in Tests.csproj to netcoreapp3.1 and add the cleaning function to it.
using NUnit.Framework;
namespace <MyProject>.Tests.<Package>
{
[TestFixture]
public class <MyClassTests>
{
[SetUp]
public void SetUp()
{
// Code here will be run once before every test.
}
[TearDown]
public void TearDown()
{
// Code here will be run once after every test.
}
[Test]
public void FunctionBeingTested1_Condition_ExpectedResult()
{
// Write some test code.
// e.g. Assert.AreEqual(expectedValue, actualValue);
}
[Test]
[Repeat(100)]
public void FunctionBeingTested2_Condition_ExpectedResult()
{
// Tests can also be repeated N times.
// Here, this test will be repeated 100 times.
// Write some test code.
// e.g. Assert.AreEqual(expectedValue, actualValue);
}
}
}
dotnet test //for running the tests
dotnet clean //for clean the folders
dotnet build //for building the app
Windows:
dotnet clean
dotnet build
dotnet publish -r win-x64 -c release -o ./Build
Mac:
dotnet clean
dotnet build
dotnet publish -r osx-x64 -c release -o ./Build
Linux:
dotnet clean
dotnet build
dotnet publish -r linux-x64 -c release -o ./Build