Skip to content

Commit

Permalink
Use dotnet CLI in Cake to support building without Mono (MonoGame#7112)
Browse files Browse the repository at this point in the history
* Fix/suppress pack warnings for CP and MGCB

* Support build script on Linux/Mac without Mono

* Suppress warning for templates project

* Re-add NETFX 4.6 target for Flatpak packager + add ref assemblies

* Typos
  • Loading branch information
Jjagg authored Apr 16, 2020
1 parent 48b99df commit efc6e92
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,19 @@ This package provides you with the content pipeline for Windows, Mac and Linux w
</Compile>
</ItemGroup>

<!-- Build and copy MFFXC, just don't reference it! -->
<!-- Build and copy MGFXC, just don't reference it! -->
<PropertyGroup>
<!-- NuGet warns if we copy assemblies but don't reference them; we suppress those warnings. -->
<NoWarn>NU5100</NoWarn>
</PropertyGroup>
<ItemGroup>
<Content Include="..\Artifacts\MonoGame.Effect.Compiler\Release\*" Visible="false">
<Content Include="..\Artifacts\MonoGame.Effect.Compiler\Release\*"
Exclude="..\Artifacts\MonoGame.Effect.Compiler\Release\*.nupkg"
Visible="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="BuildMFGXC" BeforeTargets="Restore">
<Target Name="BuildMGFXC" BeforeTargets="Restore">
<MSBuild Projects="..\Tools\MonoGame.Effect.Compiler\MonoGame.Effect.Compiler.csproj" Properties="Configuration=Release;UseAppHost=False" Targets="Restore" />
<MSBuild Projects="..\Tools\MonoGame.Effect.Compiler\MonoGame.Effect.Compiler.csproj" Properties="Configuration=Release;UseAppHost=False" Targets="Build" />
</Target>
Expand Down
8 changes: 8 additions & 0 deletions MonoGame.Framework/MonoGame.Framework.DesktopGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ This package provides you with MonoGame Framework that uses OpenGL for rendering
<PackageId>MonoGame.Framework.DesktopGL</PackageId>
</PropertyGroup>

<!-- NETFX reference assemblies let us target .NET Framework on Mac/Linux without Mono -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Compile Remove="bin\**\*" />
<Compile Remove="obj\**\*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>

<NoWarn>NU5128</NoWarn>
</PropertyGroup>
<ItemGroup>
<Content Include="content\**\*" Exclude="content\**\.DS_Store;content\**\bin;content\**\obj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
<Content Include="version\Version.props" PackagePath="build\version\$(PackageVersion)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 8 additions & 2 deletions Tools/MonoGame.Content.Builder/MonoGame.Content.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
<ProjectReference Include="..\..\MonoGame.Framework.Content.Pipeline\MonoGame.Framework.Content.Pipeline.csproj" />
</ItemGroup>

<!-- Build and copy MFFXC, just don't reference it! -->
<!-- Build and copy MGFXC, just don't reference it! -->
<PropertyGroup>
<!-- NuGet warns if we copy assemblies but don't reference them; we suppress those warnings. -->
<NoWarn>NU5100</NoWarn>
</PropertyGroup>
<ItemGroup>
<Content Include="..\..\Artifacts\MonoGame.Effect.Compiler\Release\*" Visible="false">
<Content Include="..\..\Artifacts\MonoGame.Effect.Compiler\Release\*"
Exclude="..\..\Artifacts\MonoGame.Effect.Compiler\Release\*.nupkg"
Visible="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="15.1.1012" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.1012" />

<PackageReference Update="@(PackageReference)" PrivateAssets="All" />

<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
42 changes: 19 additions & 23 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ MSBuildSettings msPackSettings, mdPackSettings;
DotNetCoreMSBuildSettings dnBuildSettings;
DotNetCorePackSettings dnPackSettings;

private void PackProject(string filePath)
private void PackMSBuild(string filePath)
{
MSBuild(filePath, msPackSettings);
}

private void PackDotnet(string filePath)
{
DotNetCorePack(filePath, dnPackSettings);
}

private bool GetMSBuildWith(string requires)
{
if (IsRunningOnWindows())
Expand Down Expand Up @@ -60,6 +65,7 @@ Task("Prep")
msPackSettings = new MSBuildSettings();
msPackSettings.Verbosity = Verbosity.Minimal;
msPackSettings.Configuration = configuration;
msPackSettings.Restore = true;
msPackSettings.WithProperty("Version", version);
msPackSettings.WithTarget("Pack");

Expand All @@ -83,7 +89,7 @@ Task("BuildDesktopGL")
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.DesktopGL.csproj");
PackProject("MonoGame.Framework/MonoGame.Framework.DesktopGL.csproj");
PackDotnet("MonoGame.Framework/MonoGame.Framework.DesktopGL.csproj");
});

Task("TestDesktopGL")
Expand All @@ -104,7 +110,7 @@ Task("BuildWindowsDX")
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.WindowsDX.csproj");
PackProject("MonoGame.Framework/MonoGame.Framework.WindowsDX.csproj");
PackDotnet("MonoGame.Framework/MonoGame.Framework.WindowsDX.csproj");
});

Task("TestWindowsDX")
Expand All @@ -130,8 +136,7 @@ Task("BuildAndroid")
return DirectoryExists("/Library/Frameworks/Xamarin.Android.framework");
}).Does(() =>
{
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.Android.csproj");
PackProject("MonoGame.Framework/MonoGame.Framework.Android.csproj");
PackMSBuild("MonoGame.Framework/MonoGame.Framework.Android.csproj");
});

Task("BuildiOS")
Expand All @@ -141,45 +146,37 @@ Task("BuildiOS")
return DirectoryExists("/Library/Frameworks/Xamarin.iOS.framework");
}).Does(() =>
{
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.iOS.csproj");
PackProject("MonoGame.Framework/MonoGame.Framework.iOS.csproj");
PackMSBuild("MonoGame.Framework/MonoGame.Framework.iOS.csproj");
});

Task("BuildUWP")
.IsDependentOn("Prep")
.WithCriteria(() => GetMSBuildWith("Microsoft.VisualStudio.Component.Windows10SDK.17763"))
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.WindowsUniversal.csproj");
PackProject("MonoGame.Framework/MonoGame.Framework.WindowsUniversal.csproj");
PackMSBuild("MonoGame.Framework/MonoGame.Framework.WindowsUniversal.csproj");
});

Task("BuildContentPipeline")
.IsDependentOn("Prep")
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj");
PackProject("MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj");
PackDotnet("MonoGame.Framework.Content.Pipeline/MonoGame.Framework.Content.Pipeline.csproj");
});

Task("BuildTools")
.IsDependentOn("Prep")
.Does(() =>
{
DotNetCoreRestore("Tools/MonoGame.Content.Builder/MonoGame.Content.Builder.csproj");
PackProject("Tools/MonoGame.Content.Builder/MonoGame.Content.Builder.csproj");
PackDotnet("Tools/MonoGame.Content.Builder/MonoGame.Content.Builder.csproj");

DotNetCoreRestore("Tools/MonoGame.Effect.Compiler/MonoGame.Effect.Compiler.csproj");
PackProject("Tools/MonoGame.Effect.Compiler/MonoGame.Effect.Compiler.csproj");
PackDotnet("Tools/MonoGame.Effect.Compiler/MonoGame.Effect.Compiler.csproj");

DotNetCoreRestore("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.csproj");
PackProject("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.csproj");
PackDotnet("Tools/MonoGame.Content.Builder.Editor/MonoGame.Content.Builder.Editor.csproj");

DotNetCoreRestore("Tools/MonoGame.Content.Builder.Task/MonoGame.Content.Builder.Task.csproj");
PackProject("Tools/MonoGame.Content.Builder.Task/MonoGame.Content.Builder.Task.csproj");
PackDotnet("Tools/MonoGame.Content.Builder.Task/MonoGame.Content.Builder.Task.csproj");

DotNetCoreRestore("Tools/MonoGame.Packaging.Flatpak/MonoGame.Packaging.Flatpak.csproj");
PackProject("Tools/MonoGame.Packaging.Flatpak/MonoGame.Packaging.Flatpak.csproj");
PackDotnet("Tools/MonoGame.Packaging.Flatpak/MonoGame.Packaging.Flatpak.csproj");
});

Task("TestTools")
Expand All @@ -198,8 +195,7 @@ Task("PackDotNetTemplates")
.IsDependentOn("Prep")
.Does(() =>
{
DotNetCoreRestore("Templates/MonoGame.Templates.CSharp/MonoGame.Templates.CSharp.csproj");
PackProject("Templates/MonoGame.Templates.CSharp/MonoGame.Templates.CSharp.csproj");
PackDotnet("Templates/MonoGame.Templates.CSharp/MonoGame.Templates.CSharp.csproj");
});

Task("PackVSTemplates")
Expand Down

0 comments on commit efc6e92

Please sign in to comment.