diff --git a/.vsts-ci.yml b/.vsts-ci.yml index bfa95549e..7e9bc79af 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -33,6 +33,8 @@ variables: - name: PostBuildSign value: true - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - name: Codeql.Enabled + value: true - group: DotNet-DotNetCli-Storage - group: DotNet-Installer-SDLValidation-Params - name: _PublishUsingPipelines diff --git a/NuGet.config b/NuGet.config index 08a242e88..cb866adcb 100644 --- a/NuGet.config +++ b/NuGet.config @@ -32,6 +32,8 @@ + + diff --git a/README.md b/README.md index 4a1955267..c56604d4a 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ Please see the [dotnet/source-build](https://github.com/dotnet/source-build) rep ## Support -.NET Source-Build is supported on the oldest available .NET SDK feature update, and on Linux only. -For example, if both .NET 6.0.1XX and 6.0.2XX feature updates are available from [dotnet.microsoft.com](https://dotnet.microsoft.com/en-us/download/dotnet/6.0), Source-Build will only support 6.0.1XX. +.NET Source-Build is supported on the oldest available .NET SDK feature update for each major release, and on Linux only. +For example, if .NET 6.0.1xx, 6.0.2xx, and 7.0.1xx feature updates are available from [dotnet.microsoft.com](https://dotnet.microsoft.com/en-us/download/dotnet/6.0), Source-Build will support 6.0.1xx and 7.0.1xx. For the latest information about Source-Build support for new .NET versions, please check our [GitHub Discussions page](https://github.com/dotnet/source-build/discussions) for announcements. ## Prerequisites @@ -88,7 +88,7 @@ The dependencies for building .NET from source can be found [here](https://githu ``` This builds the entire .NET SDK from source. - The resulting SDK is placed at `artifacts/x64/Release/dotnet-sdk-6.0.100-fedora.33-x64.tar.gz`. + The resulting SDK is placed at `artifacts/x64/Release/dotnet-sdk-7.0.100-your-RID.tar.gz`. Optionally add the `--online` flag to add online NuGet restore sources to the build. This is useful for testing unsupported releases that don't yet build without downloading pre-built binaries from the internet. @@ -99,7 +99,7 @@ The dependencies for building .NET from source can be found [here](https://githu ```bash mkdir -p $HOME/dotnet - tar zxf artifacts/x64/Release/dotnet-sdk-6.0.100-fedora.33-x64.tar.gz -C $HOME/dotnet + tar zxf artifacts/x64/Release/dotnet-sdk-7.0.100-your-RID.tar.gz -C $HOME/dotnet ln -s $HOME/dotnet/dotnet /usr/bin/dotnet ``` diff --git a/eng/ManualVersions.props b/eng/ManualVersions.props index 7707ace1a..2bf456f30 100644 --- a/eng/ManualVersions.props +++ b/eng/ManualVersions.props @@ -9,11 +9,11 @@ Basically: In this file, choose the highest version when resolving merge conflicts. --> - 10.0.17763.27 - 10.0.18362.27 - 10.0.19041.27 - 10.0.20348.27 - 10.0.22000.27 - 10.0.22621.27 + 10.0.17763.28 + 10.0.18362.28 + 10.0.19041.28 + 10.0.20348.28 + 10.0.22000.28 + 10.0.22621.28 diff --git a/eng/Signing.props b/eng/Signing.props index 3a2373f9e..0d49f78d1 100644 --- a/eng/Signing.props +++ b/eng/Signing.props @@ -7,12 +7,9 @@ - - - - - - + + + diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index a2831d574..9ebca97ff 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -11,6 +11,7 @@ $(InnerBuildArgs) /p:IncludeNuGetPackageArchive=false $(InnerBuildArgs) /p:IncludeAdditionalSharedFrameworks=false $(InnerBuildArgs) /p:IncludeSharedFrameworksForBackwardsCompatibilityTests=false + $(InnerBuildArgs) /p:DISABLE_CROSSGEN=true diff --git a/src/SourceBuild/tarball/content/build.sh b/src/SourceBuild/tarball/content/build.sh index b6056a426..a6ea077ff 100755 --- a/src/SourceBuild/tarball/content/build.sh +++ b/src/SourceBuild/tarball/content/build.sh @@ -9,6 +9,7 @@ usage() { echo " --online build using online sources" echo " --poison build with poisoning checks" echo " --run-smoke-test don't build; run smoke tests" + echo " --use-mono-runtime output uses the mono runtime" echo " --with-packages use the specified directory of previously-built packages" echo " --with-sdk use the SDK in the specified directory for bootstrapping" echo "use -- to send the remaining arguments to MSBuild" @@ -45,6 +46,9 @@ while :; do runningSmokeTests=true MSBUILD_ARGUMENTS+=( "-t:RunSmokeTest" ) ;; + --use-mono-runtime) + MSBUILD_ARGUMENTS+=( "/p:SourceBuildUseMonoRuntime=true" ) + ;; --with-packages) CUSTOM_PACKAGES_DIR="$(cd -P "$2" && pwd)" if [ ! -d "$CUSTOM_PACKAGES_DIR" ]; then diff --git a/src/SourceBuild/tarball/content/eng/bootstrap/OverrideBootstrapVersions.props b/src/SourceBuild/tarball/content/eng/bootstrap/OverrideBootstrapVersions.props new file mode 100644 index 000000000..d0a05029f --- /dev/null +++ b/src/SourceBuild/tarball/content/eng/bootstrap/OverrideBootstrapVersions.props @@ -0,0 +1,11 @@ + + + + 7.0.0-rtm.22518.5 + + $(NonshippingRuntimeVersionFor700) + $(NonshippingRuntimeVersionFor700) + $(NonshippingRuntimeVersionFor700) + + diff --git a/src/SourceBuild/tarball/content/eng/bootstrap/buildBootstrapPreviouslySB.csproj b/src/SourceBuild/tarball/content/eng/bootstrap/buildBootstrapPreviouslySB.csproj index 9a00e2a48..a22d70373 100644 --- a/src/SourceBuild/tarball/content/eng/bootstrap/buildBootstrapPreviouslySB.csproj +++ b/src/SourceBuild/tarball/content/eng/bootstrap/buildBootstrapPreviouslySB.csproj @@ -2,6 +2,7 @@ + net7.0 diff --git a/src/SourceBuild/tarball/content/eng/pipelines/security-partners-dotnet.yml b/src/SourceBuild/tarball/content/eng/pipelines/security-partners-dotnet.yml new file mode 100644 index 000000000..69bef21e9 --- /dev/null +++ b/src/SourceBuild/tarball/content/eng/pipelines/security-partners-dotnet.yml @@ -0,0 +1,18 @@ +trigger: none + +jobs: +- template: ../../src/installer/src/SourceBuild/Arcade/eng/common/templates/job/source-build-build-tarball.yml + parameters: + architecture: x64 + excludeSdkContentTests: true + matrix: + Ubuntu2004-Offline: + _BootstrapPrep: false + _Container: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-20220813234344-4c008dd + _EnablePoison: false + _ExcludeOmniSharpTests: false + _RunOnline: false + name: Build_Tarball_x64 + pool: + name: NetCore1ESPool-Svc-Internal + demands: ImageOverride -equals Build.Ubuntu.1804.Amd64 diff --git a/src/SourceBuild/tarball/content/prep.sh b/src/SourceBuild/tarball/content/prep.sh index e348e1dcc..c90dab9ac 100755 --- a/src/SourceBuild/tarball/content/prep.sh +++ b/src/SourceBuild/tarball/content/prep.sh @@ -121,7 +121,7 @@ if [ "$buildBootstrap" == "true" ]; then fi # Run restore on project to initiate download of bootstrap packages - $DOTNET_SDK_PATH/dotnet restore $workingDir/buildBootstrapPreviouslySB.csproj /bl:artifacts/prep/bootstrap.binlog /fileLoggerParameters:LogFile=artifacts/prep/bootstrap.log /p:ArchiveDir="$SCRIPT_ROOT/packages/archive/" + $DOTNET_SDK_PATH/dotnet restore $workingDir/buildBootstrapPreviouslySB.csproj /bl:artifacts/prep/bootstrap.binlog /fileLoggerParameters:LogFile=artifacts/prep/bootstrap.log /p:ArchiveDir="$SCRIPT_ROOT/packages/archive/" /p:BootstrapOverrideVersionsProps="$SCRIPT_ROOT/eng/bootstrap/OverrideBootstrapVersions.props" # Remove working directory rm -rf $workingDir diff --git a/src/SourceBuild/tarball/content/repos/Directory.Build.props b/src/SourceBuild/tarball/content/repos/Directory.Build.props index e4e3060af..04ab89d11 100644 --- a/src/SourceBuild/tarball/content/repos/Directory.Build.props +++ b/src/SourceBuild/tarball/content/repos/Directory.Build.props @@ -143,6 +143,7 @@ $(StandardSourceBuildArgs) /p:AdditionalSourceBuiltNupkgCacheDir="$(SourceBuiltPackagesPath)" $(StandardSourceBuildArgs) /p:ReferencePackageNupkgCacheDir="$(ReferencePackagesDir)" $(StandardSourceBuildArgs) /p:PreviouslySourceBuiltNupkgCacheDir="$(PrebuiltSourceBuiltPackagesPath)" + $(StandardSourceBuildArgs) /p:SourceBuildUseMonoRuntime=$(SourceBuildUseMonoRuntime) $(ProjectDirectory)\build$(ShellExtension) diff --git a/src/SourceBuild/tarball/content/repos/fsharp.proj b/src/SourceBuild/tarball/content/repos/fsharp.proj index bc9a10be7..3ffd14406 100644 --- a/src/SourceBuild/tarball/content/repos/fsharp.proj +++ b/src/SourceBuild/tarball/content/repos/fsharp.proj @@ -27,6 +27,7 @@ + osx-x64 $(OverrideTargetRid.Substring(0, $(OverrideTargetRid.IndexOf("-")))) + + <_platformIndex>$(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-')) + $(NETCoreSdkPortableRuntimeIdentifier.Substring(0, $(_platformIndex))) + --runtime-id $(OverrideTargetRid) --runtime-id $(TargetRid) @@ -22,6 +26,7 @@ --> $(BuildCommandArgs) /p:NETCoreAppMaximumVersion=99.9 $(BuildCommandArgs) /p:OSName=$(OSNameOverride) + $(BuildCommandArgs) /p:PortableOSName=$(PortableOS) $(BuildCommandArgs) /p:Rid=$(TargetRid) $(BuildCommandArgs) /p:DOTNET_INSTALL_DIR=$(DotNetCliToolDir) diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs index ae5508aa4..921ab1f97 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetHelper.cs @@ -96,7 +96,7 @@ internal class DotNetHelper } } - public void ExecuteCmd(string args, string? workingDirectory = null, Action? additionalProcessConfigCallback = null, int expectedExitCode = 0, int millisecondTimeout = -1) + public void ExecuteCmd(string args, string? workingDirectory = null, Action? additionalProcessConfigCallback = null, int? expectedExitCode = 0, int millisecondTimeout = -1) { (Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess( DotNetPath, @@ -105,7 +105,9 @@ internal class DotNetHelper configure: (process) => configureProcess(process, workingDirectory), millisecondTimeout: millisecondTimeout); - ExecuteHelper.ValidateExitCode(executeResult, expectedExitCode); + if (expectedExitCode != null) { + ExecuteHelper.ValidateExitCode(executeResult, (int) expectedExitCode); + } void configureProcess(Process process, string? workingDirectory) { diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetWatchTests.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetWatchTests.cs index f2dc2a75b..4c5a9c425 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetWatchTests.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DotNetWatchTests.cs @@ -13,20 +13,18 @@ public class DotNetWatchTests : SmokeTests { public DotNetWatchTests(ITestOutputHelper outputHelper) : base(outputHelper) { } - // TODO: Re-enable https://github.com/dotnet/source-build/issues/2961 - // [Fact] + //[Fact] - Renable with https://github.com/dotnet/source-build/issues/3123 public void WatchTests() { string projectDirectory = DotNetHelper.ExecuteNew(DotNetTemplate.Console.GetName(), nameof(DotNetWatchTests)); bool outputChanged = false; - // We expect an exit code of 143 (128 + 15, i.e. SIGTERM) because we are killing the process manually DotNetHelper.ExecuteCmd( "watch run", workingDirectory: projectDirectory, additionalProcessConfigCallback: processConfigCallback, - expectedExitCode: 143, - millisecondTimeout: 30000); + expectedExitCode: null, // The exit code does not reflect whether or not dotnet watch is working properly + millisecondTimeout: 60000); Assert.True(outputChanged); @@ -53,7 +51,7 @@ public class DotNetWatchTests : SmokeTests { outputChanged = true; OutputHelper.WriteLine("Successfully re-ran program after code change."); - ExecuteHelper.ExecuteProcessValidateExitCode("kill", $"-s TERM {process.Id}", OutputHelper); + process.Kill(true); } }); } diff --git a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs index 570b5accb..b8b4e7d8d 100644 --- a/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs +++ b/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs @@ -70,7 +70,7 @@ internal static class ExecuteHelper if (!process.HasExited) { - outputHelper.WriteLine($"Killing: {fileName} {args}"); + outputHelper.WriteLine($"Process did not exit. Killing {fileName} {args} after waiting {millisecondTimeout} milliseconds."); process.Kill(true); process.WaitForExit(); } diff --git a/src/SourceBuild/tarball/patches/aspnetcore/0001-ResolvePackageFileConflicts-workaround.patch b/src/SourceBuild/tarball/patches/aspnetcore/0001-ResolvePackageFileConflicts-workaround.patch new file mode 100644 index 000000000..ab355630e --- /dev/null +++ b/src/SourceBuild/tarball/patches/aspnetcore/0001-ResolvePackageFileConflicts-workaround.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MichaelSimons +Date: Fri, 11 Nov 2022 21:10:54 +0000 +Subject: [PATCH] ResolvePackageFileConflicts workaround + +--- + .../App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj +index 3b5d2ae950..f92fb421fe 100644 +--- a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj ++++ b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj +@@ -253,6 +253,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant + + + ++ ++ ++ + + + diff --git a/src/SourceBuild/tarball/patches/aspnetcore/0003-Address-obsolete-errors.patch b/src/SourceBuild/tarball/patches/aspnetcore/0003-Address-obsolete-errors.patch new file mode 100644 index 000000000..b98759d70 --- /dev/null +++ b/src/SourceBuild/tarball/patches/aspnetcore/0003-Address-obsolete-errors.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MichaelSimons +Date: Thu, 27 Oct 2022 02:47:08 +0000 +Subject: [PATCH] Address obsolete errors + +Backport: https://github.com/dotnet/aspnetcore/pull/44734 +--- + src/Servers/Kestrel/Core/src/KestrelServerOptions.cs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Servers/Kestrel/Core/src/KestrelServerOptions.cs b/src/Servers/Kestrel/Core/src/KestrelServerOptions.cs +index f31880e891..fc6322dd41 100644 +--- a/src/Servers/Kestrel/Core/src/KestrelServerOptions.cs ++++ b/src/Servers/Kestrel/Core/src/KestrelServerOptions.cs +@@ -252,9 +252,6 @@ public class KestrelServerOptions + writer.WritePropertyName(nameof(AllowResponseHeaderCompression)); + writer.WriteBooleanValue(AllowResponseHeaderCompression); + +- writer.WritePropertyName(nameof(EnableAltSvc)); +- writer.WriteBooleanValue(EnableAltSvc); +- + writer.WritePropertyName(nameof(IsDevCertLoaded)); + writer.WriteBooleanValue(IsDevCertLoaded); + diff --git a/src/SourceBuild/tarball/patches/format/0001-Address-Microsoft.Build.Locator-prebuilt.patch b/src/SourceBuild/tarball/patches/format/0001-Address-Microsoft.Build.Locator-prebuilt.patch new file mode 100644 index 000000000..e8b8f38fd --- /dev/null +++ b/src/SourceBuild/tarball/patches/format/0001-Address-Microsoft.Build.Locator-prebuilt.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MichaelSimons +Date: Tue, 15 Nov 2022 17:34:00 +0000 +Subject: [PATCH] Address Microsoft.Build.Locator prebuilt + +Backport: https://github.com/dotnet/format/issues/1759 +--- + Directory.Packages.props | 2 +- + eng/Versions.props | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Directory.Packages.props b/Directory.Packages.props +index c4bf3cf..f7e85b2 100644 +--- a/Directory.Packages.props ++++ b/Directory.Packages.props +@@ -10,7 +10,7 @@ + + + +- ++ + + + +diff --git a/eng/Versions.props b/eng/Versions.props +index fcd583b..2933963 100644 +--- a/eng/Versions.props ++++ b/eng/Versions.props +@@ -14,6 +14,7 @@ + + + 17.3.0-preview-22302-02 ++ 1.5.5 + 3.3.3 + 7.0.0-rc.1.22426.10 + diff --git a/src/finalizer/finalizer.cpp b/src/finalizer/finalizer.cpp index c8f5eca6b..d68418b9b 100644 --- a/src/finalizer/finalizer.cpp +++ b/src/finalizer/finalizer.cpp @@ -447,7 +447,17 @@ extern "C" HRESULT DetectSdk(LPWSTR sczSdkFeatureBandVersion, LPWSTR sczArchitec LogStringLine(REPORT_STANDARD, "Scanning %ls", sczInstalledSdkVersionsKeyName); hr = RegOpen(HKEY_LOCAL_MACHINE, sczInstalledSdkVersionsKeyName, KEY_READ, &hkInstalledSdkVersionsKey); - ExitOnFailure(hr, "Failed to read installed versions key."); + + // When the last SDK is removed the registry key should no longer exist so we can just exit + if (E_FILENOTFOUND == hr) + { + LogStringLine(REPORT_STANDARD, "Registry key not found: %ls.", sczInstalledSdkVersionsKeyName); + hr = S_OK; + *pbInstalled = FALSE; + goto LExit; + } + + ExitOnFailure(hr, "Failed to open registry key: %ls.", sczInstalledSdkVersionsKeyName); for (DWORD dwSdkVersionsValueIndex = 0;; ++dwSdkVersionsValueIndex) { @@ -509,9 +519,10 @@ int wmain(int argc, wchar_t* argv[]) hr = ::DetectSdk(sczFeatureBandVersion, argv[3], &bSdkFeatureBandInstalled); ExitOnFailure(hr, "Failed to detect installed SDKs."); - if (!bSdkFeatureBandInstalled) + // If the feature band is still present, do not remove workloads. + if (bSdkFeatureBandInstalled) { - LogStringLine(REPORT_STANDARD, "SDK with feature band %ls could not be found.", sczFeatureBandVersion); + LogStringLine(REPORT_STANDARD, "Detected SDK with feature band %ls.", sczFeatureBandVersion); goto LExit; } diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets index 6279fe883..9f4da5dc4 100644 --- a/src/redist/targets/Crossgen.targets +++ b/src/redist/targets/Crossgen.targets @@ -29,7 +29,27 @@ BuildInParallel="False" Projects="@(CrossGenDownloadPackageProject)"> - + + + + net8.0 + + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\NuGet.Build.Tasks.Pack\CoreCLR\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Razor\tasks\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.ILLink.Tasks\tools\net7.0\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Publish\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Web\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Web.ProjectSystem\tools\$(DefaultToolTfm)\ + $(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Worker\tools\$(DefaultToolTfm)\ + + @@ -49,16 +69,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -121,6 +141,21 @@ false + + + + + + + + + + + + + + + osx freebsd linux - + + $(Rid.Substring(0, $(Rid.LastIndexOf('-')))) $(HostOSName) - $(OSName)-$(Architecture) + $(OSName) + + $(OSName)-$(Architecture) + + $(PortableOSName)-$(Architecture) @@ -24,12 +29,9 @@ - $(Rid) - $(OSName)-$(Architecture) + $(Rid) - $(HostOSName)-$(Architecture) + $(PortableRid) dotnet-sdk-internal$(PgoTerm) dotnet-sdk$(PgoTerm) diff --git a/src/redist/targets/packaging/deb/postinst b/src/redist/targets/packaging/deb/postinst index 615c17e6b..696ec8acc 100644 --- a/src/redist/targets/packaging/deb/postinst +++ b/src/redist/targets/packaging/deb/postinst @@ -4,6 +4,5 @@ first_run() { /usr/share/dotnet/dotnet exec /usr/share/dotnet/sdk/%SDK_VERSION%/dotnet.dll internal-reportinstallsuccess "debianpackage" > /dev/null 2>&1 || true } -INSTALL_TEMP_HOME=/tmp/dotnet-installer -[ -d $INSTALL_TEMP_HOME ] || mkdir $INSTALL_TEMP_HOME +INSTALL_TEMP_HOME=$(mktemp -d) # mktemp should set 700 perm automatically HOME=$INSTALL_TEMP_HOME first_run diff --git a/src/redist/targets/packaging/osx/clisdk/scripts/postinstall b/src/redist/targets/packaging/osx/clisdk/scripts/postinstall index 28339be99..86710223d 100644 --- a/src/redist/targets/packaging/osx/clisdk/scripts/postinstall +++ b/src/redist/targets/packaging/osx/clisdk/scripts/postinstall @@ -12,7 +12,7 @@ first_run() { $INSTALL_DESTINATION/dotnet exec $INSTALL_DESTINATION/sdk/%SDK_VERSION%/dotnet.dll internal-reportinstallsuccess "$1" > /dev/null 2>&1 || true } -[ -d $INSTALL_TEMP_HOME ] || mkdir $INSTALL_TEMP_HOME +INSTALL_TEMP_HOME=$(mktemp -d) # mktemp should set 700 perm automatically HOME=$INSTALL_TEMP_HOME first_run exit 0 diff --git a/src/redist/targets/packaging/windows/clisdk/bundle.wxs b/src/redist/targets/packaging/windows/clisdk/bundle.wxs index 346e66d75..bac843303 100644 --- a/src/redist/targets/packaging/windows/clisdk/bundle.wxs +++ b/src/redist/targets/packaging/windows/clisdk/bundle.wxs @@ -151,7 +151,31 @@ - + + + + + @@ -208,20 +232,7 @@ - - + diff --git a/test/EndToEnd/EndToEnd.Tests.csproj b/test/EndToEnd/EndToEnd.Tests.csproj index 56776d61d..278ac08fd 100644 --- a/test/EndToEnd/EndToEnd.Tests.csproj +++ b/test/EndToEnd/EndToEnd.Tests.csproj @@ -1,6 +1,7 @@  $(CoreSdkTargetFramework) + $(DefineConstants);LINUX_PORTABLE diff --git a/test/EndToEnd/GivenFrameworkDependentApps.cs b/test/EndToEnd/GivenFrameworkDependentApps.cs index 13cafcf7a..0d30abdac 100644 --- a/test/EndToEnd/GivenFrameworkDependentApps.cs +++ b/test/EndToEnd/GivenFrameworkDependentApps.cs @@ -47,39 +47,44 @@ namespace EndToEnd internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion) { - var testProjectCreator = new TestProjectCreator() - { - PackageName = packageName, - MinorVersion = minorVersion, - }; - - var _testInstance = testProjectCreator.Create(); - - string projectDirectory = _testInstance.Root.FullName; - - string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj"); - - // Get the resolved version of .NET Core - new RestoreCommand() - .WithWorkingDirectory(projectDirectory) - .Execute() - .Should().Pass(); - - string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json"); - var assetsFile = new LockFileFormat().Read(assetsFilePath); - - var versionInAssertsJson = GetPackageVersion(assetsFile, packageName); - versionInAssertsJson.Should().NotBeNull(); - - if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0) - { - // if the bundled version is, for example, a prerelease of - // .NET Core 2.1.1, that we don't roll forward to that prerelease - // version for framework-dependent deployments. + // https://github.com/NuGet/Home/issues/8571 + #if LINUX_PORTABLE return; - } + #else + var testProjectCreator = new TestProjectCreator() + { + PackageName = packageName, + MinorVersion = minorVersion, + }; - versionInAssertsJson.ToNormalizedString().Should().BeEquivalentTo(GetExpectedVersion(packageName, minorVersion)); + var _testInstance = testProjectCreator.Create(); + + string projectDirectory = _testInstance.Root.FullName; + + string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj"); + + // Get the resolved version of .NET Core + new RestoreCommand() + .WithWorkingDirectory(projectDirectory) + .Execute() + .Should().Pass(); + + string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json"); + var assetsFile = new LockFileFormat().Read(assetsFilePath); + + var versionInAssertsJson = GetPackageVersion(assetsFile, packageName); + versionInAssertsJson.Should().NotBeNull(); + + if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0) + { + // if the bundled version is, for example, a prerelease of + // .NET Core 2.1.1, that we don't roll forward to that prerelease + // version for framework-dependent deployments. + return; + } + + versionInAssertsJson.ToNormalizedString().Should().BeEquivalentTo(GetExpectedVersion(packageName, minorVersion)); + #endif } private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) diff --git a/test/EndToEnd/TelemetryOptOutDefaultTests.cs b/test/EndToEnd/TelemetryOptOutDefaultTests.cs new file mode 100644 index 000000000..1e2d2ecef --- /dev/null +++ b/test/EndToEnd/TelemetryOptOutDefaultTests.cs @@ -0,0 +1,24 @@ +using System.IO; +using FluentAssertions; +using Microsoft.DotNet.Tools.Test.Utilities; +using Xunit; + +namespace EndToEnd.Tests +{ + public class TelemetryOptOutDefault : TestBase + { + [Fact] + public void TelemetryOptOutDefaultAttribute() + { + var versionCommand = new DotnetCommand() + .ExecuteWithCapturedOutput("--version"); + + var sdkVersion = versionCommand.StdOut.Trim(); + + var dotnetdir = Path.Combine(Path.GetDirectoryName(RepoDirectoriesProvider.DotnetUnderTest), "sdk", sdkVersion); + + var result = AssemblyInfo.Get(Path.Combine(dotnetdir, "dotnet.dll"), "AssemblyMetadataAttribute"); + result.Should().Contain("TelemetryOptOutDefault:False"); + } + } +} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/AssemblyInfo.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/AssemblyInfo.cs new file mode 100644 index 000000000..f02cfbeb3 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/AssemblyInfo.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection.Metadata; +using System.Reflection.PortableExecutable; +using System.Text; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public static class AssemblyInfo + { + public static IList Get(string assemblyPath, string assemblyInfoName) + { + var list = new List(); + + using (var stream = File.OpenRead(assemblyPath)) + using (var peReader = new PEReader(stream)) + { + var metadataReader = peReader.GetMetadataReader(); + var assemblyDefinition = metadataReader.GetAssemblyDefinition(); + + foreach (var handle in assemblyDefinition.GetCustomAttributes()) + { + var attribute = metadataReader.GetCustomAttribute(handle); + var constructor = metadataReader.GetMemberReference((MemberReferenceHandle)attribute.Constructor); + var type = metadataReader.GetTypeReference((TypeReferenceHandle)constructor.Parent); + var name = metadataReader.GetString(type.Name); + + if (name.Equals(assemblyInfoName)) + { + var signature = metadataReader.GetBlobReader(constructor.Signature); + var value = metadataReader.GetBlobReader(attribute.Value); + var header = signature.ReadSignatureHeader(); + + const ushort prolog = 1; // two-byte "prolog" defined by ECMA-335 (II.23.3) to be at the beginning of attribute value blobs + if (value.ReadUInt16() != prolog || header.Kind != SignatureKind.Method || header.IsGeneric) + { + throw new BadImageFormatException(); + } + + var paramCount = signature.ReadCompressedInteger(); + if (paramCount <= 0 || // must have at least 1 parameter + signature.ReadSignatureTypeCode() != SignatureTypeCode.Void) // return type must be void + { + continue; + } + + var sb = new StringBuilder(); + while (paramCount > 0 && sb != null) + { + switch (signature.ReadSignatureTypeCode()) + { + case SignatureTypeCode.String: + sb.Append(value.ReadSerializedString()); + break; + default: + sb = null; + break; + } + + paramCount--; + if (paramCount != 0) + { + sb?.Append(':'); + } + } + + if (sb != null) + { + list.Add(sb.ToString()); + } + } + } + } + return list; + } + } +}