Skip to content
Open
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
7 changes: 0 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<!-- Disable NuGet audit in official builds. MSBuild does not correctly handle
WarningsNotAsErrors for NuGet warnings (https://github.com/dotnet/msbuild/issues/10801),
so audit findings become errors via TreatWarningsAsErrors. -->
<PropertyGroup Condition="'$(OfficialBuild)' == 'true'">
<NuGetAudit>false</NuGetAudit>
</PropertyGroup>

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-dotnet -->
<add key="darc-pub-dotnet-dotnet-463e0cf" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-dotnet-463e0cf2/nuget/v3/index.json" />
<add key="darc-pub-dotnet-dotnet-799539e" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-dotnet-799539e5/nuget/v3/index.json" />
<add key="darc-int-dotnet-dotnet-94ea826" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-dotnet-94ea8265/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-dotnet -->
<!-- Begin: Package sources from microsoft-testfx -->
Expand Down Expand Up @@ -47,4 +47,8 @@
<!-- End: Package sources from dotnet-runtime -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
</disabledPackageSources>
<auditSources>
<clear />
<add key="nuget.org" value="https://data.nuget.org/v3/index.json" />
</auditSources>
</configuration>
268 changes: 134 additions & 134 deletions eng/Version.Details.props

Large diffs are not rendered by default.

538 changes: 269 additions & 269 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<VersionMajor>10</VersionMajor>
<VersionMinor>0</VersionMinor>
<VersionSDKMinor>3</VersionSDKMinor>
<VersionSDKMinorPatch>2</VersionSDKMinorPatch>
<VersionSDKMinorPatch>3</VersionSDKMinorPatch>
<VersionFeature>$([System.String]::Copy('$(VersionSDKMinorPatch)').PadLeft(2, '0'))</VersionFeature>
<!-- This property powers the SdkAnalysisLevel property in end-user MSBuild code.
It should always be the hundreds-value of the current SDK version, never any
Expand Down
2 changes: 2 additions & 0 deletions eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Param(
[string][Alias('v')]$verbosity = "minimal",
[string] $msbuildEngine = $null,
[bool] $warnAsError = $true,
[string] $warnNotAsError = '',
[bool] $nodeReuse = $true,
[switch] $buildCheck = $false,
[switch][Alias('r')]$restore,
Expand Down Expand Up @@ -70,6 +71,7 @@ function Print-Usage() {
Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)"
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
Write-Host " -warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
Write-Host " -warnNotAsError <value> Sets a semi-colon delimited list of warning codes that should not be treated as errors"
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio"
Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)"
Expand Down
6 changes: 6 additions & 0 deletions eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ usage()
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
echo " --nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
echo " --warnAsError <value> Sets warnaserror msbuild parameter ('true' or 'false')"
echo " --warnNotAsError <value> Sets a semi-colon delimited list of warning codes that should not be treated as errors"
echo " --buildCheck <value> Sets /check msbuild parameter"
echo " --fromVMR Set when building from within the VMR"
echo ""
Expand Down Expand Up @@ -78,6 +79,7 @@ ci=false
clean=false

warn_as_error=true
warn_not_as_error=''
node_reuse=true
build_check=false
binary_log=false
Expand Down Expand Up @@ -176,6 +178,10 @@ while [[ $# > 0 ]]; do
warn_as_error=$2
shift
;;
-warnnotaserror)
warn_not_as_error=$2
shift
;;
-nodereuse)
node_reuse=$2
shift
Expand Down
20 changes: 19 additions & 1 deletion eng/common/core-templates/job/onelocbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ parameters:
CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex
GithubPat: $(BotAccount-dotnet-bot-repo-PAT)

# Service connection for WIF-based Entra authentication to ceapex feeds (replaces CeapexPat).
# When set, dnceng/internal builds acquire a federated Entra token instead of using a PAT.
# All other projects (e.g. DevDiv, public), where this dnceng-scoped service connection does not
# exist, and any pipeline that sets this to '' fall back to PAT-based auth via the CeapexPat parameter.
CeapexServiceConnection: 'dnceng-onelocbuild-ceapex'

SourcesDirectory: $(System.DefaultWorkingDirectory)
CreatePr: true
AutoCompletePr: false
Expand Down Expand Up @@ -73,6 +79,15 @@ jobs:
displayName: Generate LocProject.json
condition: ${{ parameters.condition }}

# Acquire an Entra token for ceapex feed access via WIF (dnceng/internal only).
# All other projects use PAT-based auth, since the ceapex service connection is scoped to dnceng/internal.
- ${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}:
- template: /eng/common/templates/steps/get-federated-access-token.yml
parameters:
federatedServiceConnection: ${{ parameters.CeapexServiceConnection }}
outputVariableName: 'CeapexEntraToken'
condition: ${{ parameters.condition }}

- task: OneLocBuild@2
displayName: OneLocBuild
env:
Expand All @@ -88,7 +103,10 @@ jobs:
isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }}
isShouldReusePrSelected: ${{ parameters.ReusePr }}
packageSourceAuth: patAuth
patVariable: ${{ parameters.CeapexPat }}
${{ if and(ne(parameters.CeapexServiceConnection, ''), eq(variables['System.TeamProject'], 'internal')) }}:
patVariable: $(CeapexEntraToken)
${{ if or(eq(parameters.CeapexServiceConnection, ''), ne(variables['System.TeamProject'], 'internal')) }}:
patVariable: ${{ parameters.CeapexPat }}
${{ if eq(parameters.RepoType, 'gitHub') }}:
repoType: ${{ parameters.RepoType }}
gitHubPatVariable: "${{ parameters.GithubPat }}"
Expand Down
3 changes: 0 additions & 3 deletions eng/common/core-templates/job/publish-build-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ jobs:

# Populate internal runtime variables.
- template: /eng/common/templates/steps/enable-internal-sources.yml
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
parameters:
legacyCredential: $(dn-bot-dnceng-artifact-feeds-rw)

- template: /eng/common/templates/steps/enable-internal-runtimes.yml

Expand Down
2 changes: 0 additions & 2 deletions eng/common/core-templates/post-build/post-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ stages:

# Populate internal runtime variables.
- template: /eng/common/templates/steps/enable-internal-sources.yml
parameters:
legacyCredential: $(dn-bot-dnceng-artifact-feeds-rw)

- template: /eng/common/templates/steps/enable-internal-runtimes.yml

Expand Down
1 change: 1 addition & 0 deletions eng/common/dotnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ $dotnetRoot = InitializeDotNetCli -install:$true
if ($args.count -gt 0) {
$env:DOTNET_NOLOGO=1
& "$dotnetRoot\dotnet.exe" $args
ExitWithExitCode $LASTEXITCODE
}
10 changes: 9 additions & 1 deletion eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
# Configures warning treatment in msbuild.
[bool]$warnAsError = if (Test-Path variable:warnAsError) { $warnAsError } else { $true }

# Specifies semi-colon delimited list of warning codes that should not be treated as errors.
[string]$warnNotAsError = if (Test-Path variable:warnNotAsError) { $warnNotAsError } else { '' }

# Specifies which msbuild engine to use for build: 'vs', 'dotnet' or unspecified (determined based on presence of tools.vs in global.json).
[string]$msbuildEngine = if (Test-Path variable:msbuildEngine) { $msbuildEngine } else { $null }

Expand Down Expand Up @@ -732,7 +735,7 @@ function InitializeToolset() {

'<Project Sdk="Microsoft.DotNet.Arcade.Sdk"/>' | Set-Content $proj

MSBuild-Core $proj $bl /t:__WriteToolsetLocation /clp:ErrorsOnly`;NoSummary /p:__ToolsetLocationOutputFile=$toolsetLocationFile
MSBuild-Core $proj $bl /t:__WriteToolsetLocation /clp:ErrorsOnly`;NoSummary /p:__ToolsetLocationOutputFile=$toolsetLocationFile /p:RestoreIgnoreFailedSources=true

$path = Get-Content $toolsetLocationFile -Encoding UTF8 -TotalCount 1
if (!(Test-Path $path)) {
Expand Down Expand Up @@ -836,6 +839,11 @@ function MSBuild-Core() {
$cmdArgs += ' /p:TreatWarningsAsErrors=false'
}

if ($warnAsError -and $warnNotAsError) {
$escapedWarnNotAsError = $warnNotAsError -replace ';', '%3B'
$cmdArgs += " /warnnotaserror:$warnNotAsError /p:AdditionalWarningsNotAsErrors=$escapedWarnNotAsError"
}

foreach ($arg in $args) {
if ($null -ne $arg -and $arg.Trim() -ne "") {
if ($arg.EndsWith('\')) {
Expand Down
12 changes: 10 additions & 2 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ fi
# Configures warning treatment in msbuild.
warn_as_error=${warn_as_error:-true}

# Specifies semi-colon delimited list of warning codes that should not be treated as errors.
warn_not_as_error=${warn_not_as_error:-''}

# True to attempt using .NET Core already that meets requirements specified in global.json
# installed on the machine instead of downloading one.
use_installed_dotnet_cli=${use_installed_dotnet_cli:-true}
Expand Down Expand Up @@ -430,7 +433,7 @@ function InitializeToolset {
fi

echo '<Project Sdk="Microsoft.DotNet.Arcade.Sdk"/>' > "$proj"
MSBuild-Core "$proj" $bl /t:__WriteToolsetLocation /clp:ErrorsOnly\;NoSummary /p:__ToolsetLocationOutputFile="$toolset_location_file"
MSBuild-Core "$proj" $bl /t:__WriteToolsetLocation /clp:ErrorsOnly\;NoSummary /p:__ToolsetLocationOutputFile="$toolset_location_file" /p:RestoreIgnoreFailedSources=true

local toolset_build_proj=`cat "$toolset_location_file"`

Expand Down Expand Up @@ -532,7 +535,12 @@ function MSBuild-Core {
mt_switch="-mt"
fi

RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@"
local warnnotaserror_switch=""
if [[ -n "$warn_not_as_error" && "$warn_as_error" == true ]]; then
warnnotaserror_switch="/warnnotaserror:$warn_not_as_error /p:AdditionalWarningsNotAsErrors=${warn_not_as_error//;/%3B}"
fi

RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch $mt_switch $warnnotaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@"
}

function GetDarc {
Expand Down
11 changes: 6 additions & 5 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
".dotnet",
"$host$"
],
"errorMessage": "The .NET SDK is not installed or is not configured correctly. Please run ./build to install the correct SDK version locally."
"errorMessage": "The .NET SDK is not installed or is not configured correctly. Please run ./build to install the correct SDK version locally.",
"version": "10.0.302"
},
"tools": {
"dotnet": "10.0.301",
"dotnet": "10.0.302",
"runtimes": {
"dotnet": [
"$(MicrosoftNETCorePlatformsPackageVersion)"
Expand All @@ -21,10 +22,10 @@
}
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.26360.107",
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.26360.107",
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.26372.117",
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.26372.117",
"Microsoft.Build.NoTargets": "3.7.0",
"Microsoft.Build.Traversal": "3.4.0",
"Microsoft.WixToolset.Sdk": "5.0.2-dotnet.3009129"
"Microsoft.WixToolset.Sdk": "6.0.3-dotnet.6"
}
}
95 changes: 78 additions & 17 deletions src/Containers/Microsoft.NET.Build.Containers/ContentStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,18 @@ namespace Microsoft.NET.Build.Containers;

internal static class ContentStore
{
public static string ArtifactRoot { get; set; } = Path.Combine(Path.GetTempPath(), "Containers");
public static string ArtifactRoot { get; set; } = EnsureCacheDirectory();
public static string ContentRoot
{
get
{
string contentPath = Path.Join(ArtifactRoot, "Content");

Directory.CreateDirectory(contentPath);

CreateCacheDirectory(contentPath);
return contentPath;
}
}

public static string TempPath
{
get
{
string tempPath = Path.Join(ArtifactRoot, "Temp");

Directory.CreateDirectory(tempPath);

return tempPath;
}
}
public static string TempPath { get; } = Directory.CreateTempSubdirectory().FullName;

public static string PathForDescriptor(Descriptor descriptor)
{
Expand Down Expand Up @@ -62,8 +50,81 @@ public static string GetPathForHash(string contentHash)
return Path.Combine(ContentRoot, contentHash);
}

public static string GetTempFile()
public static string GetTempFile() => Path.Join(TempPath, Path.GetRandomFileName());

/// <summary>
/// Gets the path to the user cache directory for SDK container builds, creating it if it does
/// not already exist.
/// </summary>
private static string EnsureCacheDirectory()
{
string userCacheDir = GetUserCacheDirectoryPath();
CreateCacheDirectory(userCacheDir);

string dotnetCacheDir = Path.Join(userCacheDir, "dotnet");
CreateCacheDirectory(dotnetCacheDir);

string containersCacheDir = Path.Join(dotnetCacheDir, "Containers");
CreateCacheDirectory(containersCacheDir);

return containersCacheDir;
}

/// <summary>
/// Creates a cache directory with user-scoped permissions based on the OS.
/// </summary>
/// <remarks>
/// Permissions are only set for the leaf directory. The caller is expected to handle
/// permissions for intermediate directories.
/// </remarks>
private static void CreateCacheDirectory(string path)
{
if (OperatingSystem.IsWindows())
{
Directory.CreateDirectory(path);
}
else
{
// Per XDG_CACHE_HOME spec: if the cache directory doesn't exist, try to create it with
// permissions 0700. If it already exists, don't try to change the permissions.
// See https://specifications.freedesktop.org/basedir/latest/#referencing
Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute);
}
}

/// <summary>
/// Gets the user-scoped cache directory, accounting for OS differences.
/// </summary>
private static string GetUserCacheDirectoryPath()
{
return Path.Join(TempPath, Path.GetRandomFileName());
if (OperatingSystem.IsLinux())
{
// See "XDG Base Directory Specification":
// https://specifications.freedesktop.org/basedir/latest/
string? xdgCacheHome = Environment.GetEnvironmentVariable("XDG_CACHE_HOME");
if (!string.IsNullOrEmpty(xdgCacheHome) && Path.IsPathFullyQualified(xdgCacheHome))
{
return xdgCacheHome;
}

// From the spec, if XDG_CACHE_HOME is not set then fall back to ~/.cache
string userHomeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
return Path.Join(userHomeDirectory, ".cache");
}

if (OperatingSystem.IsMacOS())
{
// See "macOS Library Directory Details":
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html
string userHomeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
return Path.Join(userHomeDirectory, "Library", "Caches");
}

// On other platforms, use the local application data folder.
string localAppData = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.DoNotVerify);

return localAppData;
}
}
13 changes: 13 additions & 0 deletions src/Containers/Microsoft.NET.Build.Containers/DigestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@ internal static string GetSha(string str)

return Convert.ToHexStringLower(hash);
}

/// <summary>
/// Returns the encoded (hash) portion of a digest string as raw bytes.
/// </summary>
/// <remarks>
/// <c>GetEncodedValue("sha256:e3b0c4...")</c> returns the bytes for <c>"e3b0c4..."</c>.
/// </remarks>
internal static byte[] GetEncodedValue(string digest)
{
int separatorIndex = digest.IndexOf(':');
string encoded = separatorIndex >= 0 ? digest[(separatorIndex + 1)..] : digest;
return Convert.FromHexString(encoded);
}
}
Loading
Loading