forked from Fallout-build/Fallout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
59 lines (49 loc) · 3.06 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
59 lines (49 loc) · 3.06 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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Thanks to Thomas Frenzel (https://github.com/dotnet/sdk/issues/1151#issuecomment-385133284) -->
<PropertyGroup>
<ReplacePackageReferences Condition="$(ReplacePackageReferences) == ''">true</ReplacePackageReferences>
<SolutionPath>$(MSBuildThisFileDirectory)fallout-global.sln</SolutionPath>
</PropertyGroup>
<Choose>
<When Condition="$(ReplacePackageReferences) AND '$(SolutionPath)' != '' AND '$(SolutionPath)' != '*undefined*' AND Exists('$(SolutionPath)')">
<PropertyGroup>
<SolutionFileContent>$([System.IO.File]::ReadAllText($(SolutionPath)))</SolutionFileContent>
<SmartSolutionDir>$([System.IO.Path]::GetDirectoryName( $(SolutionPath) ))</SmartSolutionDir>
<RegexPattern>(?<="[PackageName]", ")(.*)(?=", ")</RegexPattern>
</PropertyGroup>
<ItemGroup>
<!-- Keep the identity of the package reference -->
<SmartPackageReference Include="@(PackageReference)">
<PackageName>%(Identity)</PackageName>
<InSolution>$(SolutionFileContent.Contains('\%(Identity).csproj'))</InSolution>
</SmartPackageReference>
<!-- Filter them by mapping them to another itemGroup using the WithMetadataValue item function -->
<PackageInSolution Include="@(SmartPackageReference -> WithMetadataValue('InSolution', True) )">
<Pattern>$(RegexPattern.Replace('[PackageName]','%(PackageName)') )</Pattern>
<SmartPath>$([System.Text.RegularExpressions.Regex]::Match( '$(SolutionFileContent)', '%(Pattern)' ))</SmartPath>
</PackageInSolution>
<ProjectReference Include="@(PackageInSolution -> '$(SmartSolutionDir)\%(SmartPath)' )"/>
<!-- Remove the package references that are now referenced as projects -->
<PackageReference Remove="@(PackageInSolution -> '%(PackageName)' )"/>
</ItemGroup>
</When>
</Choose>
<!-- Nerdbank.GitVersioning emits its Git*/NBGV_* cloud-build variables (and build number)
to $GITHUB_ENV once per project. In a parallel multi-project build these concurrent,
unsynchronized appends race and can tear a line — e.g. the CalVer version "2026.1.0"
fragmenting so the tail "6.1.0" lands on its own line — which the GitHub Actions runner
rejects with "Unable to process file command 'env' … Invalid format". The version is
read via ThisAssembly at compile time and no workflow consumes these variables, so
suppress the emission by clearing the items/property NBGV's writer targets are gated on.
Order-independent: relies on BeforeTargets scheduling, not import order. See ADR-0004. -->
<Target Name="FalloutDisableNbgvCloudVars"
BeforeTargets="SetCloudBuildVersionVars;SetCloudBuildNumberWithVersion">
<ItemGroup>
<CloudBuildVersionVars Remove="@(CloudBuildVersionVars)" />
</ItemGroup>
<PropertyGroup>
<CloudBuildNumber></CloudBuildNumber>
</PropertyGroup>
</Target>
</Project>