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 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 git -C $MY_DIR clone -b fix-MonoGame-FNA https://github.com/prime31/ImGui.NET.git --recursive
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Finished downloading!\n" echo "Finished downloading!"
else else
echo >&2 "ERROR: Unable to download successfully. Maybe try again later?" echo >&2 "ERROR: Unable to download successfully. Maybe try again later?"
fi 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" 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 else
echo "nuget restore Nez.FNA/Nez/Nez.sln && msbuild Nez.FNA/Nez/Nez.sln && msbuild /t:restore $newProjectName" | pbcopy 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 fi

View File

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