-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
26 lines (21 loc) · 1.35 KB
/
Copy pathDirectory.Build.props
File metadata and controls
26 lines (21 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<Project>
<Import Project="$(MSBuildThisFileDirectory)Common.props" />
<PropertyGroup>
<!-- Attempt to read a .env file from the solution root -->
<DotEnvFile>$(MSBuildThisFileDirectory).env</DotEnvFile>
</PropertyGroup>
<PropertyGroup Condition="Exists('$(DotEnvFile)')">
<!-- Read file into a temporary property -->
<_TempDotEnvContent>$([System.IO.File]::ReadAllText('$(DotEnvFile)'))</_TempDotEnvContent>
<!-- Regex to find AVALONIA_LICENSE_KEY=value
(?m) enables multiline mode so ^ matches start of line
^\s* matches start of line and optional whitespace
\s*=\s* matches equals sign with optional whitespace around it
([^\s#]+) matches the value until whitespace or comment start -->
<AvaloniaLicenseKeyPattern>(?m)^\s*AVALONIA_LICENSE_KEY\s*=\s*([^\s#]+)</AvaloniaLicenseKeyPattern>
<!-- Extract key (an existing AVALONIA_LICENSE_KEY environment variable takes precedence) -->
<AVALONIA_LICENSE_KEY Condition="'$(AVALONIA_LICENSE_KEY)' == ''">$([System.Text.RegularExpressions.Regex]::Match($(_TempDotEnvContent), $(AvaloniaLicenseKeyPattern)).Groups[1].Value)</AVALONIA_LICENSE_KEY>
<!-- Clear the temporary property to prevent secrets from leaking into build logs -->
<_TempDotEnvContent/>
</PropertyGroup>
</Project>