Skip to content

Commit b3d1eb6

Browse files
wtgodbeCopilot
andcommitted
Put package build assets in TFM-specific folders
When a package has a build/ or buildMultiTargeting/ folder without a TFM subfolder, NuGet considers it compatible with any TFM. This causes builds that should fail at restore to instead hit confusing runtime errors. Change PackagePath in csproj/nuspec to pack build assets into TFM subfolders (e.g., build/net11.0/ instead of build/). The source files themselves keep their original relative paths — NuGet resolves the TFM subfolder at restore time, and the relative directory structure within the package mirrors the source layout. Affected packages: - Microsoft.AspNetCore.SpaProxy - Microsoft.AspNetCore.Identity.UI - Microsoft.AspNetCore.Components.WebView - Microsoft.AspNetCore.Grpc.JsonTranscoding - Microsoft.Extensions.ApiDescription.Client Fixes #58990 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c31cb17 commit b3d1eb6

15 files changed

Lines changed: 33 additions & 27 deletions

File tree

src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<_BlazorModulesFilePath>..\..\..\..\WebView\src\blazor.modules.json</_BlazorModulesFilePath>
1010
</PropertyGroup>
1111

12-
<Import Project="..\..\..\..\WebView\src\buildTransitive\Microsoft.AspNetCore.Components.WebView.props" />
12+
<Import Project="..\..\..\..\WebView\src\build\Microsoft.AspNetCore.Components.WebView.props" />
1313

1414
<ItemGroup>
1515
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Components.WebView.Photino.csproj" />

src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<EmbeddedFilesManifestFileName>Microsoft.Extensions.FileProviders.Embedded.Manifest.xml</EmbeddedFilesManifestFileName>
77
<IsShippingPackage>true</IsShippingPackage>
88
<DefineConstants>$(DefineConstants);BLAZOR_WEBVIEW</DefineConstants>
9-
<NoWarn>$(NoWarn);BL0006</NoWarn>
9+
<NoWarn>$(NoWarn);BL0006;NU5129</NoWarn>
1010
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1111
<Nullable>annotations</Nullable>
1212
</PropertyGroup>
@@ -33,9 +33,9 @@
3333
</ItemGroup>
3434

3535
<ItemGroup>
36-
<None Include="buildTransitive\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="%(Identity)" />
37-
<None Include="buildMultiTargeting\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="%(Identity)" />
38-
<None Include="build\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="%(Identity)" />
36+
<None Include="buildTransitive\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="buildTransitive\$(DefaultNetCoreTargetFramework)\" />
37+
<None Include="buildMultiTargeting\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="buildMultiTargeting\$(DefaultNetCoreTargetFramework)\" />
38+
<None Include="build\Microsoft.AspNetCore.Components.WebView.props" Pack="true" PackagePath="build\$(DefaultNetCoreTargetFramework)\" />
3939
</ItemGroup>
4040

4141
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Project>
2-
<Import Project="..\build\Microsoft.AspNetCore.Components.WebView.props" />
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\build\$(TargetFramework)\Microsoft.AspNetCore.Components.WebView.props"/>
33
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Project>
2-
<Import Project="..\build\Microsoft.AspNetCore.Components.WebView.props" />
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\build\$(TargetFramework)\Microsoft.AspNetCore.Components.WebView.props"/>
33
</Project>

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<Description>HTTP API for gRPC ASP.NET Core</Description>
44
<PackageTags>gRPC RPC HTTP/2 REST</PackageTags>
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
6+
<!-- Suppress NU5129: build assets are intentionally in TFM subfolders -->
7+
<NoWarn>$(NoWarn);NU5129</NoWarn>
68
</PropertyGroup>
79

810
<ItemGroup>
@@ -48,7 +50,7 @@
4850
<!-- See https://github.com/dotnet/aspnetcore/issues/52006 for more details. -->
4951
<None Include="build\*.targets">
5052
<Pack>true</Pack>
51-
<PackagePath>build;buildTransitive</PackagePath>
53+
<PackagePath>build\$(DefaultNetCoreTargetFramework);buildTransitive\$(DefaultNetCoreTargetFramework)</PackagePath>
5254
</None>
5355
</ItemGroup>
5456
</Project>

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/build/Microsoft.AspNetCore.Grpc.JsonTranscoding.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- This saves the developer having to find and copy these files to the right location when doing gRPC JSON transcoding. -->
55
<PropertyGroup>
66
<!-- The path of the proto files. Content from the nupkg. -->
7-
<GrpcJsonTranscoding_ProtosPath>$( [System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)../content/protos) )</GrpcJsonTranscoding_ProtosPath>
7+
<GrpcJsonTranscoding_ProtosPath>$( [System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)../../content/protos) )</GrpcJsonTranscoding_ProtosPath>
88
</PropertyGroup>
99

1010
<!-- Run immediately before the Protobuf_BeforeCompile extension point. -->

src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
1111

1212
<PackageThirdPartyNoticesFile>$(MSBuildThisFileDirectory)THIRD-PARTY-NOTICES.TXT</PackageThirdPartyNoticesFile>
13+
<!-- Suppress NU5129: build assets are intentionally in TFM subfolders (build/<tfm>/) -->
14+
<NoWarn>$(NoWarn);NU5129</NoWarn>
1315

1416
<StaticWebAssetBasePath>Identity</StaticWebAssetBasePath>
1517
<ProvideApplicationPartFactoryAttributeTypeName>Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
@@ -28,9 +30,9 @@
2830
<ItemGroup>
2931
<None Include="@(Content)" />
3032
<Content Remove="@(Content)" />
31-
<None Include="build\*" Pack="true" PackagePath="build\" />
32-
<None Include="buildMultiTargeting\*" Pack="true" PackagePath="buildMultiTargeting\" />
33-
<None Include="buildTransitive\*" Pack="true" PackagePath="buildTransitive\" />
33+
<None Include="build\*" Pack="true" PackagePath="build\$(DefaultNetCoreTargetFramework)\" />
34+
<None Include="buildMultiTargeting\*" Pack="true" PackagePath="buildMultiTargeting\$(DefaultNetCoreTargetFramework)\" />
35+
<None Include="buildTransitive\*" Pack="true" PackagePath="buildTransitive\$(DefaultNetCoreTargetFramework)\" />
3436
</ItemGroup>
3537

3638
<ItemGroup>
@@ -187,16 +189,16 @@
187189

188190
<ItemGroup>
189191
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)IdentityUI.V4.targets">
190-
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.V4.targets</PackagePath>
192+
<PackagePath>build\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.StaticWebAssets.V4.targets</PackagePath>
191193
</StaticWebAssetPackageFile>
192194
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)IdentityUI.V4.endpoints.targets">
193-
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.V4.endpoints.targets</PackagePath>
195+
<PackagePath>build\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.StaticWebAssets.V4.endpoints.targets</PackagePath>
194196
</StaticWebAssetPackageFile>
195197
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)IdentityUI.V5.targets">
196-
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.V5.targets</PackagePath>
198+
<PackagePath>build\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.StaticWebAssets.V5.targets</PackagePath>
197199
</StaticWebAssetPackageFile>
198200
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)IdentityUI.V5.endpoints.targets">
199-
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.V5.endpoints.targets</PackagePath>
201+
<PackagePath>build\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.StaticWebAssets.V5.endpoints.targets</PackagePath>
200202
</StaticWebAssetPackageFile>
201203
</ItemGroup>
202204
</Target>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Project>
2-
<Import Project="$(MSBuildThisFileDirectory)..\buildTransitive\Microsoft.AspNetCore.Identity.UI.targets"/>
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\buildTransitive\$(TargetFramework)\Microsoft.AspNetCore.Identity.UI.targets"/>
33
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Project>
2-
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.AspNetCore.Identity.UI.targets"/>
2+
<Import Project="$(MSBuildThisFileDirectory)..\..\build\$(TargetFramework)\Microsoft.AspNetCore.Identity.UI.targets"/>
33
</Project>

src/Middleware/Spa/SpaProxy/src/Microsoft.AspNetCore.SpaProxy.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<IsTrimmable>true</IsTrimmable>
77
<EnableAOTAnalyzer>false</EnableAOTAnalyzer>
8+
<!-- Suppress NU5129: build assets are intentionally in TFM subfolders -->
9+
<NoWarn>$(NoWarn);NU5129</NoWarn>
810
<!-- This is ok since this assembly is not referenced by any application but it is loaded as a hosting startup
911
assembly for apps referencing this package-->
1012
</PropertyGroup>
@@ -14,7 +16,7 @@
1416
<Reference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
1517
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
1618
<Reference Include="Microsoft.AspNetCore.Http.Features" />
17-
<None Update="build\Microsoft.AspNetCore.SpaProxy.targets" Pack="true" PackagePath="build\Microsoft.AspNetCore.SpaProxy.targets" />
19+
<None Update="build\Microsoft.AspNetCore.SpaProxy.targets" Pack="true" PackagePath="build\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.SpaProxy.targets" />
1820
</ItemGroup>
1921

2022
</Project>

0 commit comments

Comments
 (0)