Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,19 @@ void PrintFailedTests(XElement element)
<!-- Checks if the environment variable 'SENTRY_AUTH_TOKEN' has been set and creates the SentryCliOptions.asset for the sample project
This is meant for developers - so they don't have to configure the CLI options after each clean checkout (or git clean).
Gets automatically run after 'DownloadNativeSDKs'
dotnet msbuild /t:SetupSampleSentryCliOptions src/Sentry.Unity -->
<Target Name="SetupSampleSentryCliOptions" AfterTargets="DownloadNativeSDKs" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity' AND '$(SENTRY_AUTH_TOKEN)' != ''">
dotnet msbuild /t:SamplesSetupCliOptions src/Sentry.Unity -->
<Target Name="SamplesSetupCliOptions" AfterTargets="DownloadNativeSDKs" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity' AND '$(SENTRY_AUTH_TOKEN)' != ''">
<Message Importance="High" Text="Found environment variable 'SENTRY_AUTH_TOKEN'. Creating Sentry CLI options for sample project. " />
<Exec Command="pwsh &quot;$(RepoRoot)scripts/create-sentry-cli-options.ps1&quot;"/>
<Exec Command="pwsh &quot;$(RepoRoot)scripts/samples-setup-cli-options.ps1&quot;"/>
</Target>

<!-- Checks if the environment variable 'APPLE_ID' has been set and modifies the ProjectSettings.asset for the sample project
This is meant for developers - so they don't have to configure the playersettings after each clean checkout (or git clean).
Gets automatically run after 'SamplesSetupCliOptions'
dotnet msbuild /t:SamplesSetupAppleId src/Sentry.Unity -->
<Target Name="SamplesSetupAppleId" AfterTargets="SetupSampleSentryCliOptions" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity' AND '$(APPLE_ID)' != ''">
<Message Importance="High" Text="Found environment variable 'APPLE_ID'. Setting Apple ID for sample project. " />
<Exec Command="pwsh &quot;$(RepoRoot)scripts/samples-setup-apple-id.ps1&quot;"/>
</Target>

<!-- Downloads native SDKs from the latest successful GitHub Actions workflow run.
Expand Down
31 changes: 31 additions & 0 deletions scripts/samples-setup-apple-id.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"

Write-Output "Setting up Apple Developer Team ID from environment variable"

if (-not $Env:APPLE_ID)
{
Write-Error "APPLE_ID environment variable is not set. Skipping..."
exit
}

$appleId = $Env:APPLE_ID
$projectSettingsPath = "$PSScriptRoot/../samples/unity-of-bugs/ProjectSettings/ProjectSettings.asset"
if (-not (Test-Path -Path $projectSettingsPath))
{
Write-Error "ProjectSettings.asset not found at path: $projectSettingsPath"
exit
}

$content = Get-Content -Path $projectSettingsPath -Raw
if ($content -match '(\s*)appleDeveloperTeamID:.*')
{
$updatedContent = $content -replace '(\s*)appleDeveloperTeamID:.*', "`${1}appleDeveloperTeamID: $appleId"
Set-Content -Path $projectSettingsPath -Value $updatedContent
Write-Output "Successfully updated appleDeveloperTeamID in ProjectSettings.asset"
}
else
{
Write-Error "Could not find appleDeveloperTeamID property in ProjectSettings.asset"
exit
}