MG content builder working in VS now too

This commit is contained in:
Mike 2019-02-13 18:27:08 -08:00
parent 32eb6988a2
commit 00a70f8f1e
3 changed files with 190 additions and 90 deletions

93
MonoGameContent.targets Normal file
View File

@ -0,0 +1,93 @@
<!--
The main project needs a reference to this project. We use our own instead of the default MonoGame version so we can control
where our content gets built since we don't use "Content" but instead use "CompiledContent"
<Import Project="../MonoGameContent.targets" />
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('/Library/Frameworks/Mono.framework/External/xbuild/MonoGame/v3.0/MonoGame.Common.props') ">/Library/Frameworks/Mono.framework/External/xbuild</MonoGameInstallDirectory>
<MonoGameInstallDirectory
Condition=" '$(MonoGameInstallDirectory)' == '' ">$(MSBuildProgramFiles32)</MonoGameInstallDirectory>
<ContentOutputDir>bin/DesktopGL</ContentOutputDir>
<ContentIntermediateDir>obj/DesktopGL</ContentIntermediateDir>
</PropertyGroup>
<UsingTask TaskName="MonoGame.Build.Tasks.CollectContentReferences"
AssemblyFile="\Library\Frameworks\MonoGame.framework\v3.0\MonoGame.Build.Tasks.dll" />
<!-- Add MonoGameContentReference to item type selection in Visual Studio -->
<ItemGroup>
<AvailableItemName Include="MonoGameContentReference" />
</ItemGroup>
<!-- This disables the IDE feature that skips executing msbuild in some build situations. -->
<PropertyGroup>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<Target Name="Prepare">
<PropertyGroup>
<MonoGameInstallDir>$(MonoGameInstallDirectory)\MonoGame\v3.0\</MonoGameInstallDir>
<!-- El Capitan Support -->
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/Mono.framework/Versions/Current/bin/mono') ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/local/bin/mono') ">/usr/local/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/bin/mono') ">/usr/bin/mono</MonoExe>
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And '$(MonoExe)' == '' ">mono</MonoExe>
<MonoGameContentBuilderExe Condition="'$(MonoGameContentBuilderExe)' == ''">$(MonoGameInstallDir)Tools\MGCB.exe</MonoGameContentBuilderExe>
<MonoGameContentBuilderCmd>"$(MonoGameContentBuilderExe)"</MonoGameContentBuilderCmd>
<MonoGameContentBuilderCmd Condition=" '$(OS)' != 'Windows_NT' ">$(MonoExe) $(MonoGameContentBuilderCmd)</MonoGameContentBuilderCmd>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'MacOSX'">$(MonoMacResourcePrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'iOS'">$(IPhoneResourcePrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'Android'">$(MonoAndroidAssetsPrefix)</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' != '' And !HasTrailingSlash('$(PlatformResourcePrefix)')">$(PlatformResourcePrefix)\</PlatformResourcePrefix>
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' == ''"></PlatformResourcePrefix>
<MonoGameMGCBAdditionalArguments Condition="'$(MonoGameMGCBAdditionalArguments)' ==''">/quiet</MonoGameMGCBAdditionalArguments>
<Header>/platform:$(MonoGamePlatform)</Header>
</PropertyGroup>
<!-- Get all Mono Game Content References and store them in a list -->
<!-- We do this here so we are compatible with xbuild -->
<CollectContentReferences ContentReferences="@(MonoGameContentReference)" MonoGamePlatform="$(MonoGamePlatform)">
<Output TaskParameter="Output" ItemName="ContentReferences" />
</CollectContentReferences>
<Error
Text="The MonoGame content builder executable could not be located at '$(MonoGameContentBuilderExe)'!"
Condition="!Exists('$(MonoGameContentBuilderExe)')"
/>
<Warning
Text="No Content References Found. Please make sure your .mgcb file has a build action of MonoGameContentReference"
Condition=" '%(ContentReferences.FullPath)' == '' "
/>
</Target>
<PropertyGroup>
<BuildDependsOn>
BuildContent;
$(BuildDependsOn);
</BuildDependsOn>
</PropertyGroup>
<Target Name="RunContentBuilder">
<Exec Condition=" '%(ContentReferences.FullPath)' != '' "
Command="$(MonoGameContentBuilderCmd) $(MonoGameMGCBAdditionalArguments) $(Header) /@:&quot;%(ContentReferences.FullPath)&quot; /outputDir:&quot;$(ContentOutputDir)&quot; /intermediateDir:&quot;$(ContentIntermediateDir)&quot;"
WorkingDirectory="%(ContentReferences.RootDir)%(ContentReferences.Directory)" />
<CreateItem Include="%(ContentReferences.RelativeFullPath)%(ContentReferences.ContentOutputDir)\**\*.*"
AdditionalMetadata="ContentOutputDir=%(ContentReferences.ContentDirectory)">
<Output TaskParameter="Include" ItemName="ExtraContent" />
</CreateItem>
</Target>
<Target Name="BuildContent" DependsOnTargets="Prepare;RunContentBuilder" AfterTargets="Build" Condition=" '@(MonoGameContentReference)' != '' "
Outputs="%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension)">
<CreateItem Include="%(ExtraContent.FullPath)" AdditionalMetadata="Link=$(PlatformResourcePrefix)%(ExtraContent.ContentOutputDir)%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension);CopyToOutputDirectory=PreserveNewest"
Condition="'%(ExtraContent.Filename)' != ''">
<Output TaskParameter="Include" ItemName="Content" Condition="'$(MonoGamePlatform)' != 'Android' And '$(MonoGamePlatform)' != 'iOS' And '$(MonoGamePlatform)' != 'MacOSX'" />
<Output TaskParameter="Include" ItemName="BundleResource" Condition="'$(MonoGamePlatform)' == 'MacOSX' Or '$(MonoGamePlatform)' == 'iOS'" />
<Output TaskParameter="Include" ItemName="AndroidAsset" Condition="'$(MonoGamePlatform)' == 'Android'" />
</CreateItem>
</Target>
</Project>

View File

@ -72,7 +72,7 @@ function downloadImGui()
#git -C $MY_DIR clone https://github.com/mellinoe/ImGui.NET.git --recursive
git -C $MY_DIR clone -b fix-MonoGame-FNA https://github.com/prime31/ImGui.NET.git --recursive
if [ $? -eq 0 ]; then
echo "Finished downloading!\n"
echo "Finished downloading!"
else
echo >&2 "ERROR: Unable to download successfully. Maybe try again later?"
fi
@ -214,5 +214,7 @@ if [ ! $? -eq 0 ]; then
printf "\n\nManually run the following command:\n\nnuget restore Nez.FNA/Nez/Nez.sln && msbuild Nez.FNA/Nez/Nez.sln && msbuild /t:restore $newProjectName\n\n"
else
echo "nuget restore Nez.FNA/Nez/Nez.sln && msbuild Nez.FNA/Nez/Nez.sln && msbuild /t:restore $newProjectName" | pbcopy
echo "command copied to your clipboard"
echo ""
echo "A build command was copied to your clipboard. Paste and run it now."
echo ""
fi

View File

@ -1,90 +1,95 @@
<?xml version="1.0"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net471</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<AssemblyName>project_name</AssemblyName>
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<!-- Reference FNA, Nez and ImGui projects -->
<ItemGroup>
<ProjectReference Include="../FNA/FNA.csproj" />
<ProjectReference Include="../Nez.FNA/Nez.FNA/Nez.FNA.csproj" />
<ProjectReference Include="../ImGui.NET/src/ImGui.NET/ImGui.NET.csproj"/>
</ItemGroup>
<!-- Include the Content directory (except for .fx files, since we use .fxb at runtime) -->
<ItemGroup>
<Content Include="Content/**/*.*" Exclude="**/*.fx; Content/Content-Goes-Here.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- Include the CompiledContent bin (MGCB output). Copy it to the Content folder in the build. -->
<ItemGroup>
<Content Include="CompiledContent/bin/DesktopGL/**/*.xnb">
<Link>Content/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- I can't seem to get msbuild to automatically handle content so these next two bits do nothing -->
<ItemGroup>
<MonoGameContentReference Include="CompiledContent\Content.mgcb" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
<PropertyGroup>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<!-- Copy fnalib directories to output -->
<ItemGroup>
<Content Include="..\fnalibs\x86\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x64'">
<Link>x86\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\x64\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x86'">
<Link>x64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\osx\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsOSX) == 'true'">
<Link>osx\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>lib\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib64\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>lib64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- Copy ImGui native code to output -->
<ItemGroup>
<Content Include="..\ImGui.NET\deps\cimgui\win-x86\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x64'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\win-x64\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x86'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\osx-x64\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsOSX) == 'true'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\linux-x64\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net471</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<AssemblyName>project_name</AssemblyName>
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<!-- Reference FNA, Nez and ImGui projects -->
<ItemGroup>
<ProjectReference Include="../FNA/FNA.csproj"/>
<ProjectReference Include="../Nez.FNA/Nez.FNA/Nez.FNA.csproj"/>
<ProjectReference Include="../ImGui.NET/src/ImGui.NET/ImGui.NET.csproj"/>
</ItemGroup>
<!-- Include the Content directory (except for .fx files, since we use .fxb at runtime) -->
<ItemGroup>
<Content Include="Content/**/*.*" Exclude="**/*.fx; Content/Content-Goes-Here.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- Include the CompiledContent bin (MGCB output). Copy it to the Content folder in the build. -->
<ItemGroup>
<Content Include="CompiledContent/bin/DesktopGL/**/*.xnb">
<Link>Content/%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<!-- cleanup so VS looks clean -->
<None Remove="CompiledContent\obj\**"/>
<None Remove="CompiledContent\bin\**"/>
<None Remove="CompiledContent\.*"/>
</ItemGroup>
<!-- MonoGames content pipeline needs this defined -->
<ItemGroup>
<MonoGameContentReference Include="CompiledContent\Content.mgcb"/>
</ItemGroup>
<Import Project="../MonoGameContent.targets"/>
<PropertyGroup>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<!-- Copy fnalib directories to output -->
<ItemGroup>
<Content Include="..\fnalibs\x86\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x64'">
<Link>x86\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\x64\**\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x86'">
<Link>x64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\osx\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsOSX) == 'true'">
<Link>osx\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>lib\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\fnalibs\lib64\**\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>lib64\%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- Copy ImGui native code to output -->
<ItemGroup>
<Content Include="..\ImGui.NET\deps\cimgui\win-x86\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x64'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\win-x64\*.*" Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' != 'x86'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\osx-x64\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsOSX) == 'true'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\ImGui.NET\deps\cimgui\linux-x64\*.*" Condition="'$(OS)' != 'Windows_NT' AND $(IsLinux) == 'true'">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>