8000 Repo improvements · dotnet/source-build-externals@e15ac61 · GitHub
[go: up one dir, main page]

Skip to content

Commit e15ac61

Browse files
committed
Repo improvements
1 parent d795fb1 commit e15ac61

24 files changed

+324
-499
lines changed

Directory.Build.props

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,23 @@
11
<Project>
22

33
<PropertyGroup>
4-
<ImportNetSdkFromRepoToolset>false</ImportNetSdkFromRepoToolset>
5-
<_SuppressSdkImports>true</_SuppressSdkImports>
6-
<Configuration Condition="$(Configuration) == ''">Release</Configuration>
4+
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
75
</PropertyGroup>
86

9-
<Import Condition="'$(SkipArcadeSdkImport)' != 'true'" Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
10-
<PropertyGroup>
11-
<!-- Fake, for SDK. -->
12-
<TargetFramework>netstandard2.0</TargetFramework>
13-
<!-- We have no projects targeting multiple frameworks, so don't include in output path. -->
14-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
15-
</PropertyGroup>
7+
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
168

17-
<!-- This repo's projects are entirely infrastructure and do not ship. -->
189
<PropertyGroup>
10+
<!-- This repo's projects are entirely infrastructure and do not ship. -->
1911
<IsShipping>false</IsShipping>
20-
</PropertyGroup>
2112

22-
<PropertyGroup>
2313
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
24-
<TargetsDir>$(ProjectDir)targets/</TargetsDir>
2514
<KeysDir>$(ProjectDir)keys/</KeysDir>
26-
<DotNetCliToolDir Condition="'$(DotNetCliToolDir)' == '' and '$(CustomDotNetSdkDir)' != ''">$([MSBuild]::EnsureTrailingSlash('$(CustomDotNetSdkDir)'))</DotNetCliToolDir>
27-
<DotNetCliToolDir Condition="'$(DotNetCliToolDir)' == '' and '$(DOTNET_INSTALL_DIR)' != ''">$([MSBuild]::NormalizeDirectory('$(DOTNET_INSTALL_DIR)'))</DotNetCliToolDir>
28-
<DotNetCliToolDir Condition="'$(DotNetCliToolDir)' == ''">$(ProjectDir).dotnet/</DotNetCliToolDir>
29-
<DotnetToolCommand>$(DotNetCliToolDir)dotnet</DotnetToolCommand>
15+
<SubmoduleDirectory>$(ProjectDir)src/</SubmoduleDirectory>
3016
<PatchesDir>$(ProjectDir)patches/</PatchesDir>
31-
<!-- if we're not currently building, Visual Studio will still set this -->
32-
<SDK_VERSION Condition="'$(SDK_VERSION)' == ''">$(NETCoreSdkVersion)</SDK_VERSION>
33-
<XPlatTasksDir>$(MSBuildThisFileDirectory)eng/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/</XPlatTasksDir>
34-
<XPlatTasksBinDir>$(XPlatTasksDir)bin/$(Configuration)/</XPlatTasksBinDir>
35-
<XPlatSourceBuildTasksAssembly>$(XPlatTasksBinDir)Microsoft.DotNet.SourceBuild.Tasks.XPlat.dll</XPlatSourceBuildTasksAssembly>
36-
<SdkReferenceDir>$(DotNetCliToolDir)sdk/$(SDK_VERSION)/</SdkReferenceDir>
37-
</PropertyGroup>
38-
39-
<!--
40-
'.proj' has no DefaultLanguageSourceExtension, causing **/* to be collected
41-
in Compile items! Avoid this by disabling the default items.
42-
-->
43-
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.proj'">
44-
<EnableDefaultItems>false</EnableDefaultItems>
45-
</PropertyGroup>
46-
47-
<PropertyGroup>
48-
<LogVerbosity Condition="'$(LogVerbosity)'==''">minimal</LogVerbosity>
49-
</PropertyGroup>
50-
51-
<PropertyGroup>
52-
<BuildInParallel Condition="'$(BuildInParallel)'==''">false</BuildInParallel>
53-
</PropertyGroup>
17+
<XPlatSourceBuildTasksAssembly>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.DotNet.SourceBuild.Tasks.XPlat', '$(Configuration)', '$(NetCurrent)', 'Microsoft.DotNet.SourceBuild.Tasks.XPlat.dll'))</XPlatSourceBuildTasksAssembly>
5418

55-
<PropertyGroup>
56-
<ShellExtension Condition="'$(OS)' == 'Windows_NT'">.cmd</ShellExtension>
57-
<ShellExtension Condition="'$(OS)' != 'Windows_NT'">.sh</ShellExtension>
58-
<TarBallExtension Condition="'$(OS)' == 'Windows_NT'">.zip</TarBallExtension>
59-
<TarBallExtension Condition="'$(OS)' != 'Windows_NT'">.tar.gz</TarBallExtension>
60-
</PropertyGroup>
61-
62-
<PropertyGroup>
63-
<SubmoduleDirectory Condition="'$(SubmoduleDirectory)' == ''">$(ProjectDir)src/</SubmoduleDirectory>
64-
<GitModulesPath>$(ProjectDir).gitmodules</GitModulesPath>
65-
</PropertyGroup>
66-
67-
<PropertyGroup>
68-
<!-- Init basic Arcade props, if the project importing this file doesn't use Arcade. -->
69-
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$(ProjectDir)artifacts/</ArtifactsDir>
70-
<RepositoryEngineeringDir Condition="'$(RepositoryEngineeringDir)' == ''">$(ProjectDir)eng/</RepositoryEngineeringDir>
71-
</PropertyGroup>
72-
73-
<PropertyGroup>
74-
<SourceBuiltPackagesPath>$(ArtifactsShippingPackagesDir)</SourceBuiltPackagesPath>
75-
<LoggingDir>$(BaseOutputPath)logs/</LoggingDir>
76-
</PropertyGroup>
77-
78-
<!--
79-
Semaphore path for incremental builds
80-
-->
81-
<PropertyGroup>
82-
<CompletedSemaphorePath>$(BaseIntermediatePath)semaphores/</CompletedSemaphorePath>
19+
<LogVerbosity Condition="'$(LogVerbosity)' == ''">minimal</LogVerbosity>
20+
<BuildInParallel Condition="'$(BuildInParallel)' == ''">false</BuildInParallel>
8321
</PropertyGroup>
8422

8523
</Project>

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22

3-
<Import Condition="'$(SkipArcadeSdkImport)' != 'true'" Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
3+
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
44

55
</Project>

build.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,4 @@ while [[ -h $source ]]; do
1313
done
1414

1515
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
16-
17-
sdkLine=$(grep -m 1 'dotnet' "$scriptroot/global.json")
18-
sdkPattern="\"dotnet\" *: *\"(.*)\""
19-
if [[ $sdkLine =~ $sdkPattern ]]; then
20-
export SDK_VERSION=${BASH_REMATCH[1]}
21-
fi
22-
2316
"$scriptroot/eng/common/build.sh" --build --restore "$@"

eng/Build.props

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<Project>
22

33
<ItemGroup>
4-
<ProjectToBuild Include="$(RepoRoot)eng\tasks\Microsoft.DotNet.SourceBuild.Tasks.XPlat\*.csproj">
5-
<BuildInParallel>false</BuildInParallel>
6-
</ProjectToBuild>
74
<ProjectToBuild Include="$(RepoRoot)repo-projects\*.proj" />
85
</ItemGroup>
96

eng/DotNetBuild.props

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
<!-- When altering this file, please include @dotnet/product-construction as a reviewer. -->
2-
32
<Project>
43

5-
<PropertyGroup>
6-
<GitHubRepositoryName>source-build-externals</GitHubRepositoryName>
7-
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>
8-
</PropertyGroup>
9-
104
<Target Name="AddSourceBuiltPackagesToSourceBuiltCache"
115
BeforeTargets="WritePrebuiltUsageData">
126
<ItemGroup>
137
<SourceBuiltPackageFiles Include="$(CurrentRepoSourceBuildArtifactsPackagesDir)**\*.nupkg"/>
148
</ItemGroup>
159
</Target>
10+
1611
</Project>

eng/Versions.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project>
32
<!-- Repo Version Information -->
43
<PropertyGroup>
54
<MajorVersion>10</MajorVersion>

eng/tasks/Directory.Build.props

Lines changed: 0 additions & 26 deletions
This file was deleted.

eng/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,16 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(NetCurrent)</TargetFramework>
5-
<OutputPath>$(XPlatTasksBinDir)</OutputPath>
6-
</PropertyGroup>
75

8-
<PropertyGroup>
96
<!-- Default assembly version causes CS7034. Assembly info is not necessary given this
107
msbuild task assembly is for build only purposes. -->
118
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
129
<Deterministic>False</Deterministic>
1310
</PropertyGroup>
1411

1512
<ItemGroup>
16-
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildVersion)" />
17-
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildVersion)" />
1813
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildVersion)" />
1914
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
2015
</ItemGroup>
2116

22-
<ItemGroup>
23-
<Reference Include="@(SdkAssemblyReference)" />
24-
</ItemGroup>
25-
2617
</Project>
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
// See the LICENSE file in the project root for more information.
4-
51
using System;
62
using System.IO;
73
using System.Linq;
8-
using Newtonsoft.Json;
9-
using Newtonsoft.Json.Linq;
4+
using System.Text.Json;
5+
using System.Text.Json.Nodes;
106
using Microsoft.Build.Framework;
117
using Microsoft.Build.Utilities;
128

139
namespace Microsoft.DotNet.Build.Tasks
1410
{
15-
// Takes a path to a path to a json file and a
16-
// string that represents a dotted path to an attribute
17-
// and updates that attribute with the new value provided.
1811
public class UpdateJson : Task
1912
{
2013
[Required]
@@ -30,23 +23,26 @@ public class UpdateJson : Task
3023

3124
public override bool Execute()
3225
{
33-
JObject jsonObj = JObject.Parse(File.ReadAllText(JsonFilePath));
26+
string jsonText = File.ReadAllText(JsonFilePath);
27+
JsonNode jsonNode = JsonNode.Parse(jsonText);
3428

3529
string[] escapedPathToAttributeParts = PathToAttribute.Replace("\\.", "\x1F").Split('.');
3630
for (int i = 0; i < escapedPathToAttributeParts.Length; ++i)
3731
{
3832
escapedPathToAttributeParts[i] = escapedPathToAttributeParts[i].Replace("\x1F", ".");
3933
}
40-
UpdateAttribute(jsonObj, escapedPathToAttributeParts, NewAttributeValue);
4134

42-
File.WriteAllText(JsonFilePath, jsonObj.ToString());
35+
UpdateAttribute(jsonNode, escapedPathToAttributeParts, NewAttributeValue);
36+
37+
File.WriteAllText(JsonFilePath, jsonNode.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
4338
return true;
4439
}
4540

46-
private void UpdateAttribute(JToken jsonObj, string[] path, string newValue)
41+
private void UpdateAttribute(JsonNode node, string[] path, string newValue)
4742
{
4843
string pathItem = path[0];
49-
if (jsonObj[pathItem] == null)
44+
45+
if (node is not JsonObject obj || !obj.ContainsKey(pathItem))
5046
{
5147
string message = $"Path item [{nameof(PathToAttribute)}] not found in json file.";
5248
if (SkipUpdateIfMissingKey)
@@ -57,13 +53,13 @@ private void UpdateAttribute(JToken jsonObj, string[] path, string newValue)
5753
throw new ArgumentException(message, pathItem);
5854
}
5955

60-
if (path.Length == 1)
56+
if (path.Length == 1)
6157
{
62-
jsonObj[pathItem] = newValue;
58+
obj[pathItem] = newValue;
6359
return;
6460
}
6561

66-
UpdateAttribute(jsonObj[pathItem], path.Skip(1).ToArray(), newValue);
62+
UpdateAttribute(obj[pathItem], path.Skip(1).ToArray(), newValue);
6763
}
6864
}
6965
}

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"dotnet": "10.0.100-preview.3.25201.16"
44
},
55
"msbuild-sdks": {
6-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25251.105"
6+
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25251.105",
7+
"Microsoft.Build.NoTargets": "3.7.0"
78
}
89
}

repo-projects/Directory.Build.props

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,35 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<RepositoryName>$(MSBuildProjectName)</RepositoryName>
5-
</PropertyGroup>
6-
73
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, $(MSBuildThisFileDirectory)..))" />
84

95
<PropertyGroup>
10-
<SourceDirectory Condition="'$(SourceDirectory)' == ''">$(RepositoryName)</SourceDirectory>
11-
<ProjectDirectory Condition="'$(ProjectDirectory)' == ''">$(SubmoduleDirectory)$(SourceDirectory)/</ProjectDirectory>
12-
<MinimalConsoleLogOutput Condition="'$(MinimalConsoleLogOutput)' == ''">true</MinimalConsoleLogOutput>
13-
<RepoConsoleLogFile>$(LoggingDir)$(RepositoryName).log</RepoConsoleLogFile>
14-
<RedirectRepoOutputToLog Condition="'$(MinimalConsoleLogOutput)' == 'true'">&gt;&gt; $(RepoConsoleLogFile) 2&gt;&amp;1</RedirectRepoOutputToLog>
6+
<TargetFramework>$(NetCurrent)</TargetFramework>
157

16-
<!--
17-
Repo specific semaphore path for incremental build
18-
-->
19-
<RepoCompletedSemaphorePath>$(CompletedSemaphorePath)$(RepositoryName)/</RepoCompletedSemaphorePath>
20-
</PropertyGroup>
8+
<RepositoryName>$(MSBuildProjectName)</RepositoryName>
9+
<ProjectDirectory>$(SubmoduleDirectory)$(RepositoryName)/</ProjectDirectory>
2110

22-
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
23-
<FlagParameterPrefix>-</FlagParameterPrefix>
24-
<ArcadeFalseBoolBuildArg>0</ArcadeFalseBoolBuildArg>
25-
</PropertyGroup>
26-
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
27-
<FlagParameterPrefix>--</FlagParameterPrefix>
28-
<ArcadeFalseBoolBuildArg>false</ArcadeFalseBoolBuildArg>
11+
<ArtifactsLogRepoDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsLogDir)', '$(RepositoryName)'))</ArtifactsLogRepoDir>
12+
<MinimalConsoleLogOutput Condition="'$(MinimalConsoleLogOutput)' == ''">true</MinimalConsoleLogOutput>
13+
<RepoConsoleLogFile>$(ArtifactsLogRepoDir)$(RepositoryName).log</RepoConsoleLogFile>
14+
<RedirectRepoOutputToLog Condition="'$(MinimalConsoleLogOutput)' == 'true'">&gt; $(RepoConsoleLogFile) 2&gt;&amp;1</RedirectRepoOutputToLog>
2915
</PropertyGroup>
3016

31-
<!-- A human-readable description of what's building and why. -->
32-
<PropertyGroup>
33-
<ProjectBuildReason>'$(RepositoryName)'</ProjectBuildReason>
34-
</PropertyGroup>
17+
<ItemGroup>
18+
<PatchToApply Include="$(PatchesDir)$(RepositoryName)/*.patch" />
19+
</ItemGroup>
3520

3621
<ItemGroup>
3722
<EnvironmentVariables Include="DotNetPackageVersionPropsPath=$(PackageVersionPropsPath)" />
3823
<EnvironmentVariables Include="DotNetRestorePackagesPath=$(PackagesDir)" />
3924

4025
<!-- Arcade tools.sh picks up DotNetCoreSdkDir, but we can pass DOTNET_INSTALL_DIR directly. -->
41-
<EnvironmentVariables Include="DOTNET_INSTALL_DIR=$(DotNetCliToolDir)" />
42-
<EnvironmentVariables Include="DOTNET_PATH=$(DotNetCliToolDir)" />
43-
<EnvironmentVariables Include="DOTNET_HOST_PATH=$(DotNetCliToolDir)dotnet" />
26+
<EnvironmentVariables Include="DOTNET_INSTALL_DIR=$(DotNetRoot)" />
27+
<EnvironmentVariables Include="DOTNET_PATH=$(DotNetRoot)" />
28+
<EnvironmentVariables Include="DOTNET_HOST_PATH=$(DotNetTool)" />
4429

4530
<!-- _InitializeDotNetCli is used by websdk and templating to decide whether to init the SDK -->
46-
<EnvironmentVariables Include="_InitializeDotNetCli=$(DotNetCliToolDir)" />
47-
<EnvironmentVariables Include="_DotNetInstallDir=$(DotNetCliToolDir)" />
31+
<EnvironmentVariables Include="_InitializeDotNetCli=$(DotNetRoot)" />
32+
<EnvironmentVariables Include="_DotNetInstallDir=$(DotNetRoot)" />
4833
<EnvironmentVariables Include="_InitializeToolset=$(ProjectDir)Tools/source-built/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj" Condition="'$(UseBootstrapArcade)' != 'true'" />
4934

5035
<!-- We pass '-ci', but also apply ci mode via env var for edge cases. (E.g. misbehaving inner builds.) -->
@@ -68,4 +53,9 @@
6853
<EnvironmentVariables Include="DisableTransitiveFrameworkReferenceDownloads=true" />
6954
</ItemGroup>
7055

56+
<!-- repo-projects depend on the repo tasks project to invoke custom msbuild tasks -->
57+
<ItemGroup>
58+
<ProjectReference Include="$(RepoRoot)eng\tasks\Microsoft.DotNet.SourceBuild.Tasks.XPlat\Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj" />
59+
</ItemGroup>
60+
7161
</Project>

0 commit comments

Comments
 (0)
0