Skip to content

Commit 02c526f

Browse files
authored
build game before dotnet project (#139)
1 parent 99a54a3 commit 02c526f

File tree

7 files changed

+49
-12
lines changed

7 files changed

+49
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package-dev/**/*.dll
1919
package-dev/**/*.meta
2020
package-dev/**/*.pdb
2121
package-dev/**/*.xml
22+
package-dev/**/TestSentryOptions.json
2223

2324
# Build output of Sentry.Unity
2425
sentry-unity/Assets/Plugins/Sentry/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Overall, there are two "flows" to take into account - `Development` and `Release
1515

1616
## Finding the Unity installation
1717

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

2121
```xml
2222
<Project>
23-
<!-- Other propertes & groups -->
23+
<!-- Other properties & groups -->
2424
<PropertyGroup>
2525
<UnityPath Condition="<YOUR_PATH_CONDITION>">YOUR_PATH</UnityPath>
2626
</PropertyGroup>

src/Directory.Build.props

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project>
2+
23
<PropertyGroup>
34
<Version>0.0.9</Version>
45
<LangVersion>9</LangVersion>
@@ -9,18 +10,53 @@
910
<PackageFolderName>package-dev</PackageFolderName>
1011
<PackageRuntimePath>../../$(PackageFolderName)/Runtime</PackageRuntimePath>
1112
<PackageEditorPath>../../$(PackageFolderName)/Editor</PackageEditorPath>
13+
<!-- warning NU1701: Package 'NUnit 3.5.0' was restored using '.NETFramework,Version=v4.6.1 -->
14+
<NoWarn>$(NoWarn);NU1701</NoWarn>
1215
</PropertyGroup>
16+
1317
<ItemGroup>
1418
<PackageReference Include="Roslynator.Analyzers" Version="3.0.0" PrivateAssets="All" />
1519
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
1620
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.0" PrivateAssets="All" />
1721
<PackageReference Include="Nullable" Version="1.3.0" PrivateAssets="All" />
1822
</ItemGroup>
19-
<PropertyGroup>
20-
<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>
21-
<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>
23+
24+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
25+
<UnityRoot Condition="Exists('C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Hub\Editor\$(UnityVersion)\Editor</UnityRoot>
26+
<!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine-->
27+
<UnityRoot Condition="$(UnityRoot) == '' AND Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Editor</UnityRoot>
28+
<UnityManagedPath>$(UnityRoot)\Data\Managed</UnityManagedPath>
29+
<UnityExec>$(UnityRoot)\Unity.exe</UnityExec>
30+
<StandalonePlayerName>buildWindows64Player</StandalonePlayerName>
31+
<ArtifactName>game.exe</ArtifactName>
32+
</PropertyGroup>
33+
34+
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
35+
<UnityRoot Condition="Exists('/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Hub/Editor/$(UnityVersion)/Unity.app/</UnityRoot>
2236
<!--If not using Unity Hub, tries to pick whatever Unity version is installed on the machine-->
23-
<UnityPath Condition="$(UnityPath) == '' AND Exists('C:\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll')">C:\Program Files\Unity\Editor\Data\Managed</UnityPath>
24-
<UnityPath Condition="$(UnityPath) == '' AND Exists('/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Unity.app/Contents/Managed</UnityPath>
37+
<UnityRoot Condition="$(UnityRoot) == '' AND Exists('/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll')">/Applications/Unity/Unity.app/</UnityRoot>
38+
<UnityManagedPath>$(UnityRoot)/Contents/Managed</UnityManagedPath>
39+
<UnityExec>$(UnityRoot)/Contents/MacOS/Unity</UnityExec>
40+
<StandalonePlayerName>buildMacOS64Player</StandalonePlayerName>
41+
<ArtifactName>game</ArtifactName>
2542
</PropertyGroup>
43+
44+
<!-- If Unity Libraries don't exist, run a Unity build -->
45+
<Target Name="BuildUnityProject"
46+
Condition="'$(MSBuildProjectName)' == 'Sentry.Unity' and !Exists('$(MSBuildProjectDirectory)/../../samples/unity-of-bugs/Library')"
47+
BeforeTargets="BeforeBuild">
48+
<Error Condition="$(UnityRoot) == ''" Text="Couldn't find Unity."></Error>
49+
50+
<!-- Even with a successful build, Unity will error on 'usbmuxd' or log out to std-error which breaks msbuild.
51+
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:
52+
The offending error:
53+
[usbmuxd] Stop listen thread
54+
[usbmuxd] Error:
55+
[usbmuxd] Listen thread exitingit -batchmode -nographics -logFile - -projectPath $(MSBuildProjectDirectory)/../../samples/unity-of-bugs -$(StandalonePlayerName) $(ArtifactName)
56+
Related: https://forum.unity.com/threads/6572-debugger-agent-unable-to-listen-on-27.500387/ -->
57+
<Exec Command="$(UnityExec) -quit -batchmode -nographics -logFile - -projectPath $(MSBuildProjectDirectory)/../../samples/unity-of-bugs -$(StandalonePlayerName) $(ArtifactName) "
58+
IgnoreStandardErrorWarningFormat="true"
59+
IgnoreExitCode="true"></Exec>
60+
</Target>
61+
2662
</Project>

src/Sentry.Unity.Editor/Sentry.Unity.Editor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
</PropertyGroup>
88
<ItemGroup>
99
<Reference Include="UnityEngine">
10-
<HintPath>$(UnityPath)\UnityEngine.dll</HintPath>
10+
<HintPath>$(UnityManagedPath)\UnityEngine.dll</HintPath>
1111
<Private>false</Private>
1212
</Reference>
1313
<Reference Include="UnityEditor">
14-
<HintPath>$(UnityPath)\UnityEditor.dll</HintPath>
14+
<HintPath>$(UnityManagedPath)\UnityEditor.dll</HintPath>
1515
<Private>false</Private>
1616
</Reference>
1717
</ItemGroup>

src/Sentry.Unity/Sentry.Unity.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77
<ItemGroup>
88
<Reference Include="UnityEngine">
9-
<HintPath>$(UnityPath)\UnityEngine.dll</HintPath>
9+
<HintPath>$(UnityManagedPath)\UnityEngine.dll</HintPath>
1010
<Private>false</Private>
1111
</Reference>
1212
</ItemGroup>

src/test/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</ItemGroup>
1818
<ItemGroup>
1919
<Reference Include="UnityEngine">
20-
<HintPath>$(UnityPath)/UnityEngine.dll</HintPath>
20+
<HintPath>$(UnityManagedPath)/UnityEngine.dll</HintPath>
2121
<Private>false</Private>
2222
</Reference>
2323
<Reference Include="UnityEditor.TestRunner">

src/test/Sentry.Unity.Editor.Tests/Sentry.Unity.Editor.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<Reference Include="UnityEditor">
8-
<HintPath>$(UnityPath)/UnityEditor.dll</HintPath>
8+
<HintPath>$(UnityManagedPath)/UnityEditor.dll</HintPath>
99
<Private>false</Private>
1010
</Reference>
1111
</ItemGroup>

0 commit comments

Comments
 (0)