Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply source-build patches #4404

Merged
merged 14 commits into from
Mar 15, 2022
8 changes: 3 additions & 5 deletions build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@

<!-- Common -->
<PropertyGroup>
<IsBuildOnlyXPLATProjects>$(DotNetBuildFromSource)</IsBuildOnlyXPLATProjects>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<NETFXTargetFrameworkVersion>v4.7.2</NETFXTargetFrameworkVersion>
<NETFXTargetFramework>net472</NETFXTargetFramework>
<NETCoreTargetFramework>netcoreapp3.1</NETCoreTargetFramework>
<NETCoreTargetFramework Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0</NETCoreTargetFramework>
<NETCoreTestTargetFramework>netcoreapp5.0</NETCoreTestTargetFramework>
<NetStandardVersion>netstandard2.0</NetStandardVersion>
<NetStandardVersion Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0</NetStandardVersion>
<TargetFrameworksExe>$(NETFXTargetFramework);$(NETCoreTargetFramework)</TargetFrameworksExe>
<TargetFrameworksExe Condition="'$(IsBuildOnlyXPLATProjects)' == 'true' OR '$(IsXPlat)' == 'true'">$(NETCoreTargetFramework)</TargetFrameworksExe>
<TargetFrameworksExe Condition="'$(IsXPlat)' == 'true'">$(NETCoreTargetFramework)</TargetFrameworksExe>
<TargetFrameworksExeForSigning>$(TargetFrameworksExe);netcoreapp5.0</TargetFrameworksExeForSigning>
<TargetFrameworksExeForSigning Condition=" '$(IsXPlat)' == 'true' ">$(NETCoreTargetFramework);netcoreapp5.0</TargetFrameworksExeForSigning>
<TargetFrameworksExeForSigning Condition="'$(DotNetBuildFromSource)' == 'true'">$(TargetFrameworksExe);net6.0</TargetFrameworksExeForSigning>
<TargetFrameworksLibrary>$(NETFXTargetFramework);$(NetStandardVersion)</TargetFrameworksLibrary>
<TargetFrameworksLibrary Condition="'$(IsBuildOnlyXPLATProjects)' == 'true'">$(NetStandardVersion)</TargetFrameworksLibrary>
zivkan marked this conversation as resolved.
Show resolved Hide resolved
<TargetFrameworksLibrary Condition="'$(DotNetBuildFromSource)' == 'true'">$(NETCoreTargetFramework);$(NETFXTargetFramework);$(NetStandardVersion)</TargetFrameworksLibrary>
<TargetFrameworksLibraryForSigning>$(TargetFrameworksLibrary);netcoreapp5.0</TargetFrameworksLibraryForSigning>
<TargetFrameworksLibraryForSigning Condition="'$(DotNetBuildFromSource)' == 'true'">$(TargetFrameworksLibrary);net6.0</TargetFrameworksLibraryForSigning>
<TargetFrameworksLibraryForCrossVerificationTests>$(NETFXTargetFramework);netcoreapp5.0</TargetFrameworksLibraryForCrossVerificationTests>
Expand Down Expand Up @@ -288,7 +286,7 @@
</ItemGroup>

<!-- FxCop Analyzers -->
<ItemGroup Condition="'$(Shipping)' == 'true' AND '$(SkipAnalyzers)' != 'true' AND '$(IsBuildOnlyXPLATProjects)' != 'true'">
<ItemGroup Condition="'$(Shipping)' == 'true' AND '$(SkipAnalyzers)' != 'true' AND '$(DotNetBuildFromSource)' != 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</PropertyGroup>

<!-- Projects we pack become public APIs that others can use -->
<PropertyGroup Condition=" '$(IsBuildOnlyXPLATProjects)' != 'true' and '$(PackProject)' == 'true' ">
<PropertyGroup Condition=" '$(DotNetBuildFromSource)' != 'true' and '$(PackProject)' == 'true' ">
<UsePublicApiAnalyzer Condition=" '$(UsePublicApiAnalyzer)' == '' " >true</UsePublicApiAnalyzer>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion build/packages.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<CryptographyPackagesVersion>5.0.0</CryptographyPackagesVersion>
<NuGetCoreV2Version>2.14.0-rtm-832</NuGetCoreV2Version>
<ProjectSystemManagedVersion>17.0.0-beta1-10402-05</ProjectSystemManagedVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion Condition="'$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)' == ''">3.0.0-preview6.19253.5</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
</PropertyGroup>

<!-- Test and package versions -->
Expand All @@ -34,7 +35,7 @@
<PackageReference Update="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.2" />
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" />
<PackageReference Update="Microsoft.DataAI.NuGetRecommender.Contracts" Version="2.1.0" />
<PackageReference Update="Microsoft.Extensions.CommandLineUtils" Version="1.0.1" />
<PackageReference Update="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)" />
<PackageReference Update="Microsoft.Internal.VisualStudio.Shell.Framework" Version="$(VSFrameworkVersion)" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
<PackageReference Update="Microsoft.TeamFoundationServer.ExtendedClient" Version="$(VSServicesVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Target
Name="PublishAndMergePackNupkg"
AfterTargets="AfterBuild"
Condition="'$(TargetFramework)' != '' AND '$(IsXPlat)' != 'true' AND '$(IsBuildOnlyXPLATProjects)' != 'true' AND '$(BuildingInsideVisualStudio)' != 'true'">
Condition="'$(TargetFramework)' != '' AND '$(IsXPlat)' != 'true' AND '$(DotNetBuildFromSource)' != 'true' AND '$(BuildingInsideVisualStudio)' != 'true'">
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish;ILMergeNuGetPack" />
</Target>

Expand Down Expand Up @@ -101,7 +101,7 @@
DependsOnTargets="GetILMergePlatformArg;DetermineILMergeNuGetPackInputsOutputs"
Inputs="$(PathToBuiltNuGetPack);@(BuildArtifacts)"
Outputs="$(PathToMergedNuGetPack)"
Condition="'$(TargetFramework)' != '' AND '$(IsBuildOnlyXPLATProjects)' != 'true' ">
Condition="'$(TargetFramework)' != '' AND '$(DotNetBuildFromSource)' != 'true' ">
<PropertyGroup>
<ILMergeResultDir>$([System.IO.Path]::GetDirectoryName($(PathToMergedNuGetPack)))</ILMergeResultDir>
</PropertyGroup>
Expand Down Expand Up @@ -202,18 +202,18 @@
<Target Name="CreatePackNupkg">
<PropertyGroup>
<!-- Build from source can't use ILMerge. -->
<ILMergeSubpath Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">ilmerge\</ILMergeSubpath>
<PackagePathDir Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)' AND '$(IsBuildOnlyXPLATProjects)' != 'true'">Desktop/</PackagePathDir>
<ILMergeSubpath Condition="'$(DotNetBuildFromSource)' != 'true'">ilmerge\</ILMergeSubpath>
<PackagePathDir Condition="'$(TargetFramework)' == '$(NETFXTargetFramework)'">Desktop/</PackagePathDir>
<PackagePathDir Condition="'$(TargetFramework)' == '$(NetStandardVersion)'">CoreCLR/</PackagePathDir>
</PropertyGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet.Build.Tasks.Pack.dll" Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet.Build.Tasks.Pack.dll" Condition="'$(DotNetBuildFromSource)' != 'true'">
<PackagePath>$(PackagePathDir)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)**\NuGet*.resources.dll">
<PackagePath>$(PackagePathDir)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet*.dll" Condition="'$(IsBuildOnlyXPLATProjects)' == 'true'">
<TfmSpecificPackageFile Include="$(OutputPath)\$(ILMergeSubpath)NuGet*.dll" Condition="'$(DotNetBuildFromSource)' == 'true'">
<PackagePath>$(PackagePathDir)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>NuGet executable wrapper for the dotnet CLI nuget functionality.</Description>
<TargetFrameworks>$(TargetFrameworksExeForSigning)</TargetFrameworks>
<RuntimeIdentifier Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">win7-x86</RuntimeIdentifier>
<NoWarn>$(NoWarn);CS1591;CS1701</NoWarn>
<NoWarn>$(NoWarn);CS1591;CS1701;NU5104;CA1307;CA2000</NoWarn>
<OutputType>Exe</OutputType>
<Shipping>true</Shipping>
<PackProject>true</PackProject>
Expand All @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
zivkan marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Include="System.Diagnostics.Debug" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/NuGet.Core/NuGet.Common/NuGet.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<Description>Common utilities and interfaces for all NuGet libraries.</Description>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591;CS1574</NoWarn>
<PackProject>true</PackProject>
Expand All @@ -20,7 +20,7 @@
<TargetFramework>$(NETFXTargetFramework)</TargetFramework>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' or '$(TargetFramework)' == 'net45' ">
<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' or '$(TargetFramework)' == 'net45' " >
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="mscorlib" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>NuGet's configuration settings implementation.</Description>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
nkolev92 marked this conversation as resolved.
Show resolved Hide resolved
<TargetFramework />
<PackProject>true</PackProject>
<Shipping>true</Shipping>
Expand All @@ -23,13 +23,13 @@
<ProjectReference Include="$(NuGetCoreSrcDirectory)NuGet.Common\NuGet.Common.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' or '$(TargetFramework)' == 'net45' ">
<ItemGroup Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' or '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netstandard2.0' ">
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
Comment on lines +26 to 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment, doesn't the .NET SDK add these BCL references automatically for .NET Standard?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The netstandard condition was removed from NuGet.Common.csproj, but not here.

</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NetStandardVersion)' ">
<ItemGroup Condition=" '$(TargetFramework)' == '$(NetStandardVersion)' or '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/NuGet.Core/NuGet.Frameworks/NuGet.Frameworks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

<PropertyGroup>
<Description>NuGet's understanding of target frameworks.</Description>
<TargetFrameworks Condition="'$(IsBuildOnlyXPLATProjects)' == 'true'">$(TargetFrameworksLibrary);netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">$(TargetFrameworksLibrary);net40</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibrary);net40</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591;CS1574;CS1573</NoWarn>
<PackProject>true</PackProject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == '$(NetStandardVersion)' ">
<ItemGroup Condition=" '$(TargetFramework)' == '$(NetStandardVersion)' or '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.ComponentModel.Composition" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Target
Name="PublishAndMergePackNupkg"
AfterTargets="AfterBuild"
Condition="'$(TargetFramework)' != '' AND '$(IsXPlat)' != 'true' AND '$(IsBuildOnlyXPLATProjects)' != 'true' AND '$(BuildingInsideVisualStudio)' != 'true'">
Condition="'$(TargetFramework)' != '' AND '$(IsXPlat)' != 'true' AND '$(DotNetBuildFromSource)' != 'true' AND '$(BuildingInsideVisualStudio)' != 'true'">
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish;ILMergeNPE" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static HttpRequestMessage Clone(this HttpRequestMessage request)
clone.Headers.TryAddWithoutValidation(header.Key, header.Value);
}

#if NET5_0
#if NET5_0_OR_GREATER
var clonedOptions = (IDictionary<string, object>)clone.Options;
foreach (var option in request.Options)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ public static void SetConfiguration(this HttpRequestMessage request, HttpRequest
throw new ArgumentNullException(nameof(configuration));
}

#if NET5_0
#if NET5_0_OR_GREATER
request.Options.Set(new HttpRequestOptionsKey<HttpRequestMessageConfiguration>(NuGetConfigurationKey), configuration);
#else
request.Properties[NuGetConfigurationKey] = configuration;
Expand All @@ -128,7 +128,7 @@ public static void SetConfiguration(this HttpRequestMessage request, HttpRequest
private static T GetProperty<T>(this HttpRequestMessage request, string key)
{

#if NET5_0
#if NET5_0_OR_GREATER
if (request.Options.TryGetValue<T>(new HttpRequestOptionsKey<T>(key), out T result))
#else
object result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async Task<HttpResponseMessage> SendAsync(
headerStopwatch = new Stopwatch();
stopwatches.Add(headerStopwatch);
}
#if NET5_0
#if NET5_0_OR_GREATER
requestMessage.Options.Set(new HttpRequestOptionsKey<List<Stopwatch>>(StopwatchPropertyName), stopwatches);
#else
requestMessage.Properties[StopwatchPropertyName] = stopwatches;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
List<Stopwatch> stopwatches = null;

#if NET5_0
#if NET5_0_OR_GREATER
if (request.Options.TryGetValue(
new HttpRequestOptionsKey<List<Stopwatch>>(HttpRetryHandler.StopwatchPropertyName),
out stopwatches))
Expand Down
2 changes: 1 addition & 1 deletion src/NuGet.Core/NuGet.Versioning/NuGet.Versioning.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks Condition="'$(IsBuildOnlyXPLATProjects)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' != 'true'">$(TargetFrameworks);net45</TargetFrameworks>
<TargetFramework />
<Description>NuGet's implementation of Semantic Versioning.</Description>
<PackageTags>semver;semantic versioning</PackageTags>
Expand Down