Skip to content

Commit 8deb76a

Browse files
AOT compatible: set IsAOTcompatible (#7152)
1 parent a3f6e96 commit 8deb76a

12 files changed

Lines changed: 25 additions & 22 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />
3+
<PropertyGroup Condition="'$(IsAotCompatible)' == '' And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
4+
<IsAotCompatible>true</IsAotCompatible>
5+
</PropertyGroup>
6+
</Project>

src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<NoWarn>$(NoWarn);CS1591</NoWarn>
1010
<XPLATProject>true</XPLATProject>
1111
<UsePublicApiAnalyzer>false</UsePublicApiAnalyzer>
12+
<IsAotCompatible>false</IsAotCompatible>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

src/NuGet.Core/NuGet.CommandLine.XPlat/NuGet.CommandLine.XPlat.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Shipping>true</Shipping>
88
<PackProject>true</PackProject>
99
<XPLATProject>true</XPLATProject>
10+
<IsAotCompatible>false</IsAotCompatible>
1011
<UseMSBuildLocator Condition=" '$(UseMSBuildLocator)' == '' And '$(Configuration)' == 'Debug' and '$(CI)' != 'true' ">true</UseMSBuildLocator>
1112
<!-- Microsoft.Extensions.CommandLineUtils.Sources causes nullability warnings, so we have to disable it for the project and enable in each file until we can remove the package -->
1213
<Nullable>disable</Nullable>

src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/LockFileUtils.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ private static List<SelectionCriteria> CreateCriteria(
822822
/// Clears a lock file group and replaces the first item with _._ if
823823
/// the group has items. Empty groups are left alone.
824824
/// </summary>
825-
private static void ClearIfExists<T>(IList<T> group) where T : LockFileItem
825+
private static void ClearIfExists<T>(IList<T> group, Func<string, T> factory) where T : LockFileItem
826826
{
827827
if (GroupHasNonEmptyItems(group))
828828
{
@@ -846,7 +846,7 @@ private static void ClearIfExists<T>(IList<T> group) where T : LockFileItem
846846
group.Clear();
847847

848848
// Create a new item with the _._ path
849-
var emptyItem = (T)Activator.CreateInstance(typeof(T), new[] { emptyDir });
849+
var emptyItem = factory(emptyDir);
850850

851851
// Copy over the properties from the first
852852
foreach (var pair in firstItem.Properties)
@@ -949,7 +949,7 @@ private static List<LockFileRuntimeTarget> GetRuntimeTargetLockFileItems(
949949

950950
if ((dependencyType & groupType) == LibraryIncludeFlags.None)
951951
{
952-
ClearIfExists<LockFileRuntimeTarget>(items);
952+
ClearIfExists(items, static path => new LockFileRuntimeTarget(path));
953953
}
954954

955955
return items;
@@ -1023,20 +1023,20 @@ public static void ExcludeItems(LockFileTargetLibrary lockFileLib, LibraryInclud
10231023
{
10241024
if ((dependencyType & LibraryIncludeFlags.Runtime) == LibraryIncludeFlags.None)
10251025
{
1026-
ClearIfExists(lockFileLib.RuntimeAssemblies);
1026+
ClearIfExists(lockFileLib.RuntimeAssemblies, static path => new LockFileItem(path));
10271027
lockFileLib.FrameworkAssemblies.Clear();
10281028
lockFileLib.ResourceAssemblies.Clear();
10291029
}
10301030

10311031
if ((dependencyType & LibraryIncludeFlags.Compile) == LibraryIncludeFlags.None)
10321032
{
1033-
ClearIfExists(lockFileLib.CompileTimeAssemblies);
1034-
ClearIfExists(lockFileLib.EmbedAssemblies);
1033+
ClearIfExists(lockFileLib.CompileTimeAssemblies, static path => new LockFileItem(path));
1034+
ClearIfExists(lockFileLib.EmbedAssemblies, static path => new LockFileItem(path));
10351035
}
10361036

10371037
if ((dependencyType & LibraryIncludeFlags.Native) == LibraryIncludeFlags.None)
10381038
{
1039-
ClearIfExists(lockFileLib.NativeLibraries);
1039+
ClearIfExists(lockFileLib.NativeLibraries, static path => new LockFileItem(path));
10401040
}
10411041

10421042
if ((dependencyType & LibraryIncludeFlags.ContentFiles) == LibraryIncludeFlags.None
@@ -1051,16 +1051,16 @@ public static void ExcludeItems(LockFileTargetLibrary lockFileLib, LibraryInclud
10511051
(dependencyType & LibraryIncludeFlags.Build) == LibraryIncludeFlags.None)
10521052
{
10531053
// If BuildTransitive is excluded then all build assets are cleared.
1054-
ClearIfExists(lockFileLib.Build);
1055-
ClearIfExists(lockFileLib.BuildMultiTargeting);
1054+
ClearIfExists(lockFileLib.Build, static path => new LockFileItem(path));
1055+
ClearIfExists(lockFileLib.BuildMultiTargeting, static path => new LockFileItem(path));
10561056
}
10571057
else if ((dependencyType & LibraryIncludeFlags.Build) == LibraryIncludeFlags.None)
10581058
{
10591059
if (!lockFileLib.Build.Any(item => item.Path.StartsWith("buildTransitive/", StringComparison.OrdinalIgnoreCase)))
10601060
{
10611061
// all build assets are from /build folder so just clear them all.
1062-
ClearIfExists(lockFileLib.Build);
1063-
ClearIfExists(lockFileLib.BuildMultiTargeting);
1062+
ClearIfExists(lockFileLib.Build, static path => new LockFileItem(path));
1063+
ClearIfExists(lockFileLib.BuildMultiTargeting, static path => new LockFileItem(path));
10641064
}
10651065
else
10661066
{

src/NuGet.Core/NuGet.Credentials/NuGet.Credentials.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<XPLATProject>true</XPLATProject>
1010
<UsePublicApiAnalyzer>perTfm</UsePublicApiAnalyzer>
1111
<NoWarn>$(NoWarn);RS0041</NoWarn>
12-
<IsAotCompatible>true</IsAotCompatible>
1312
</PropertyGroup>
1413

1514
<PropertyGroup Condition=" '$(IsVsixBuild)' == 'true' ">

src/NuGet.Core/NuGet.DependencyResolver.Core/NuGet.DependencyResolver.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<RootNamespace>NuGet.DependencyResolver</RootNamespace>
99
<IncludeInVSIX>true</IncludeInVSIX>
1010
<XPLATProject>true</XPLATProject>
11-
<IsAotCompatible>true</IsAotCompatible>
1211
<Description>NuGet's PackageReference dependency resolver implementation.</Description>
1312
</PropertyGroup>
1413

src/NuGet.Core/NuGet.LibraryModel/NuGet.LibraryModel.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<Shipping>true</Shipping>
88
<IncludeInVSIX>true</IncludeInVSIX>
99
<XPLATProject>true</XPLATProject>
10-
<IsAotCompatible>true</IsAotCompatible>
1110
<Description>NuGet's types and interfaces for understanding dependencies.</Description>
1211
</PropertyGroup>
1312

src/NuGet.Core/NuGet.PackageManagement/NuGet.PackageManagement.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<Shipping>true</Shipping>
99
<IncludeInVSIX>true</IncludeInVSIX>
1010
<XPLATProject>true</XPLATProject>
11-
<IsAotCompatible>true</IsAotCompatible>
1211
</PropertyGroup>
1312

1413
<PropertyGroup Condition=" '$(IsVsixBuild)' == 'true' ">

src/NuGet.Core/NuGet.Packaging/NuGet.Packaging.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<IncludeInVSIX>true</IncludeInVSIX>
1111
<XPLATProject>true</XPLATProject>
1212
<UsePublicApiAnalyzer>perTfm</UsePublicApiAnalyzer>
13+
<IsAotCompatible>false</IsAotCompatible>
1314
</PropertyGroup>
1415

1516
<PropertyGroup Condition=" '$(IsVsixBuild)' == 'true' ">

src/NuGet.Core/NuGet.ProjectModel/NuGet.ProjectModel.csproj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Shipping>true</Shipping>
88
<IncludeInVSIX>true</IncludeInVSIX>
99
<XPLATProject>true</XPLATProject>
10+
<IsAotCompatible>false</IsAotCompatible>
1011
<Description>NuGet's core types and interfaces for PackageReference-based restore, such as lock files, assets file and internal restore models.</Description>
1112
</PropertyGroup>
1213

@@ -19,8 +20,9 @@
1920
<ProjectReference Include="..\NuGet.DependencyResolver.Core\NuGet.DependencyResolver.Core.csproj" />
2021
</ItemGroup>
2122

22-
<ItemGroup>
23-
<PackageReference Include="System.Collections.Immutable" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
23+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
24+
<PackageReference Include="System.Collections.Immutable" />
25+
<PackageReference Include="System.Text.Json" />
2426
</ItemGroup>
2527

2628
<ItemGroup>
@@ -53,8 +55,4 @@
5355
<ItemGroup>
5456
<InternalsVisibleTo Include="NuGet.ProjectModel.Test" />
5557
</ItemGroup>
56-
57-
<ItemGroup>
58-
<PackageReference Include="System.Text.Json" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
59-
</ItemGroup>
6058
</Project>

0 commit comments

Comments
 (0)