Skip to content

Commit

Permalink
build game before dotnet project (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed May 6, 2021
1 parent 99a54a3 commit 02c526f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package-dev/**/*.dll
package-dev/**/*.meta
package-dev/**/*.pdb
package-dev/**/*.xml
package-dev/**/TestSentryOptions.json

# Build output of Sentry.Unity
sentry-unity/Assets/Plugins/Sentry/
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Overall, there are two "flows" to take into account - `Development` and `Release

## Finding the Unity installation

The `UnityPath` configured in `src/Directory.Build.props` does a lookup at different locations to find Unity.
The `UnityPath` in `src/Directory.Build.props` does a lookup at different locations to find Unity.
This is different per operating system. You can adjust it as needed:

```xml
<Project>
<!-- Other propertes & groups -->
<!-- Other properties & groups -->
<PropertyGroup>
<UnityPath Condition="<YOUR_PATH_CONDITION>">YOUR_PATH</UnityPath>
</PropertyGroup>
Expand Down
46 changes: 41 additions & 5 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>

<PropertyGroup>
<Version>0.0.9</Version>
<LangVersion>9</LangVersion>
Expand All @@ -9,18 +10,53 @@
<PackageFolderName>package-dev</PackageFolderName>
<PackageRuntimePath>../../$(PackageFolderName)/Runtime</PackageRuntimePath>
<PackageEditorPath>../../$(PackageFolderName)/Editor</PackageEditorPath>
<!-- warning NU1701: Package 'NUnit 3.5.0' was restored using '.NETFramework,Version=v4.6.1 -->
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Roslynator.Analyzers" Version="3.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.0" PrivateAssets="All" />
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<UnityPath Condition="Exists('C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed</UnityPath>
<UnityPath Condition="$(UnityPath) == '' AND Exists('/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/</UnityPath>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<UnityRoot Condition="Exists('C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor</UnityRoot>
<!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine-->
<UnityRoot Condition="$(UnityRoot) == '' AND Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Editor</UnityRoot>
<UnityManagedPath>$(UnityRoot)\Data\Managed</UnityManagedPath>
<UnityExec>$(UnityRoot)\Unity.exe</UnityExec>
<StandalonePlayerName>buildWindows64Player</StandalonePlayerName>
<ArtifactName>game.exe</ArtifactName>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<UnityRoot Condition="Exists('/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/</UnityRoot>
<!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine-->
<UnityPath Condition="$(UnityPath) == '' AND Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Editor\Data\Managed</UnityPath>
<UnityPath Condition="$(UnityPath) == '' AND Exists('/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Unity.app/Contents/Managed</UnityPath>
<UnityRoot Condition="$(UnityRoot) == '' AND Exists('/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Unity.app/</UnityRoot>
<UnityManagedPath>$(UnityRoot)/Contents/Managed</UnityManagedPath>
<UnityExec>$(UnityRoot)/Contents/MacOS/Unity</UnityExec>
<StandalonePlayerName>buildMacOS64Player</StandalonePlayerName>
<ArtifactName>game</ArtifactName>
</PropertyGroup>

<!-- If Unity Libraries don't exist, run a Unity build -->
<Target Name="BuildUnityProject"
Condition="'$(MSBuildProjectName)' == 'Sentry.Unity' and !Exists('$(MSBuildProjectDirectory)/../../samples/unity-of-bugs/Library')"
BeforeTargets="BeforeBuild">
<Error Condition="$(UnityRoot) == ''" Text="Couldn't find Unity."></Error>

<!-- Even with a successful build, Unity will error on 'usbmuxd' or log out to std-error which breaks msbuild.
We need to run a unity build to restore the test packages and for that reason we'll ignore errors here and assume a later step will validation the build is actually working:
The offending error:
[usbmuxd] Stop listen thread
[usbmuxd] Error:
[usbmuxd] Listen thread exitingit -batchmode -nographics -logFile - -projectPath $(MSBuildProjectDirectory)/../../samples/unity-of-bugs -$(StandalonePlayerName) $(ArtifactName)
Related: https://forum.unity.com/threads/6572-debugger-agent-unable-to-listen-on-27.500387/ -->
<Exec Command="$(UnityExec) -quit -batchmode -nographics -logFile - -projectPath $(MSBuildProjectDirectory)/../../samples/unity-of-bugs -$(StandalonePlayerName) $(ArtifactName) "
IgnoreStandardErrorWarningFormat="true"
IgnoreExitCode="true"></Exec>
</Target>

</Project>
4 changes: 2 additions & 2 deletions src/Sentry.Unity.Editor/Sentry.Unity.Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>$(UnityPath)\UnityEngine.dll</HintPath>
<HintPath>$(UnityManagedPath)\UnityEngine.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEditor">
<HintPath>$(UnityPath)\UnityEditor.dll</HintPath>
<HintPath>$(UnityManagedPath)\UnityEditor.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Unity/Sentry.Unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>$(UnityPath)\UnityEngine.dll</HintPath>
<HintPath>$(UnityManagedPath)\UnityEngine.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>$(UnityPath)/UnityEngine.dll</HintPath>
<HintPath>$(UnityManagedPath)/UnityEngine.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="UnityEditor.TestRunner">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="UnityEditor">
<HintPath>$(UnityPath)/UnityEditor.dll</HintPath>
<HintPath>$(UnityManagedPath)/UnityEditor.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
Expand Down

0 comments on commit 02c526f

Please sign in to comment.