-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
68 lines (62 loc) · 3.21 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
68 lines (62 loc) · 3.21 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<Project InitialTargets="EnsureWritableNuGetUserSettings">
<Import Project="$(MSBuildThisFileDirectory)build/NuGetHomeGuard.targets" />
<!--
NuGet unconditionally creates/reads $HOME/.nuget/NuGet before honouring any
project-, solution-, or RestoreConfigFile-level config. Sandbox images that
leave $HOME/.nuget root-owned (common when a package cache is seeded under
$HOME/.nuget/packages as root) make every raw `dotnet build` fail restore.
Repair that environmental fault before any project targets run so auditors
that invoke `dotnet` directly (process:required-build, csharp:build-WaE)
succeed without depending on DOTNET_CLI_HOME redirects in the host
orchestrator binary. See scripts/ensure-writable-nuget-home.sh and
docs/build-environment.md.
NuGetHomeGuard.targets (imported above) supplies an in-process backstop:
when the user config is present-but-unreadable, its initial target
redirects DOTNET_CLI_HOME to repository-local state so NuGet's proxy-cache
initialization survives before compilation.
-->
<Target Name="EnsureWritableNuGetUserSettings">
<Exec
Command="sh "$(MSBuildThisFileDirectory)scripts/ensure-writable-nuget-home.sh""
Condition="'$(OS)' != 'Windows_NT'"
IgnoreStandardErrorWarningFormat="true" />
</Target>
<!--
Stamp the built commit into the API assembly so the running service can
tell whether the checkout it reads configuration from has moved ahead of
what was compiled into bin/. The orchestrator deploys without rebuilding, so
a git pull advances appsettings.json without advancing bin/; the next
restart then fails closed in UnboundConfigKeyHostedValidator with no hint
that the cause is a stale build. DeployConsistencyService reads this
metadata back at startup and warns while the service is still healthy.
Runs only for CodeyBox.Api (one git invocation per build, not per
project). Never fails the build: without git, or outside a checkout, the
revision is "unknown" and the consistency check reports unknown instead
of diverged.
-->
<Target
Name="CodeyBoxEmbedBuildRevision"
BeforeTargets="GetAssemblyAttributes"
Condition="'$(MSBuildProjectName)' == 'CodeyBox.Api' and '$(DesignTimeBuild)' != 'true' and '$(CodeyBoxBuildRevision)' == ''">
<Exec
Command="git rev-parse HEAD"
WorkingDirectory="$(MSBuildThisFileDirectory)"
ConsoleToMSBuild="true"
StandardOutputImportance="Low"
StandardErrorImportance="Low"
IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CodeyBoxBuildRevision" />
</Exec>
<PropertyGroup>
<CodeyBoxBuildRevision Condition="'$(CodeyBoxBuildRevision)' == ''">unknown</CodeyBoxBuildRevision>
<CodeyBoxBuildRevision>$(CodeyBoxBuildRevision.Trim())</CodeyBoxBuildRevision>
<CodeyBoxBuildRevision Condition="'$(CodeyBoxBuildRevision)' == ''">unknown</CodeyBoxBuildRevision>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>CodeyBoxBuildRevision</_Parameter1>
<_Parameter2>$(CodeyBoxBuildRevision)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
</Project>