Skip to content

Commit e9256ea

Browse files
committed
build depending assemblies without generating the API list to avoid NU1108 error during dotnet pack
1 parent 1c142af commit e9256ea

File tree

5 files changed

+91
-44
lines changed

5 files changed

+91
-44
lines changed

src/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ SPDX-License-Identifier: MIT
1919

2020
<!-- suppress generating README.md by Smdn.MSBuild.ProjectAssets.Library -->
2121
<GeneratePackageReadmeFile>false</GeneratePackageReadmeFile>
22+
23+
<!--
24+
To avoid cyclic references (error NU1108) when making NuGet packages,
25+
disable generating API list to prevent including the reference to this package itself.
26+
-->
27+
<APIListEnableGenerating>false</APIListEnableGenerating>
2228
</PropertyGroup>
2329

2430
<PropertyGroup Label="packaging">
@@ -47,10 +53,7 @@ SPDX-License-Identifier: MIT
4753

4854
<ItemGroup>
4955
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.8.43" PrivateAssets="All" />
50-
<ProjectReference Include="private\Smdn.Reflection.ReverseGenerating.ListApi.Core.csproj" PrivateAssets="All" />
51-
52-
<!-- remove this package itself from PackageReference to avoid duplicate references during the running of 'Pack' target -->
53-
<PackageReference Remove="$(PackageId)" />
56+
<ProjectReference Include="private\Smdn.Reflection.ReverseGenerating.ListApi.Core\Smdn.Reflection.ReverseGenerating.ListApi.Core.csproj" PrivateAssets="All" />
5457
</ItemGroup>
5558

5659
<ItemGroup>

src/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks/private/Smdn.Reflection.ReverseGenerating.ListApi.Core.csproj renamed to src/Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks/private/Smdn.Reflection.ReverseGenerating.ListApi.Core/Smdn.Reflection.ReverseGenerating.ListApi.Core.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ SPDX-License-Identifier: MIT
77
<TargetFrameworks>net8.0</TargetFrameworks>
88
</PropertyGroup>
99

10-
<Import Project="..\..\Smdn.Reflection.ReverseGenerating.ListApi.Core\Smdn.Reflection.ReverseGenerating.ListApi.Core.Common.props" />
10+
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Smdn.Reflection.ReverseGenerating.ListApi.Core\Smdn.Reflection.ReverseGenerating.ListApi.Core.Common.props" />
1111

1212
<PropertyGroup>
1313
<IsPackable>false</IsPackable>
1414
<VersionSuffix>private</VersionSuffix>
15+
16+
<!--
17+
To avoid cyclic references (error NU1108) when making NuGet packages,
18+
disable generating API list to prevent including the package reference to ListApi.MSBuild.Tasks.
19+
-->
20+
<APIListEnableGenerating>false</APIListEnableGenerating>
1521
</PropertyGroup>
1622

1723
<!--
1824
Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks bundles the private build assembly with the package.
1925
So in case when Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks builds this project, use ProjectReference.
2026
-->
2127
<ItemGroup>
22-
<ProjectReference Include="..\..\Smdn.Reflection.ReverseGenerating\Smdn.Reflection.ReverseGenerating.csproj" />
28+
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Smdn.Reflection.ReverseGenerating\Smdn.Reflection.ReverseGenerating.csproj" />
2329
</ItemGroup>
2430
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
<Project Sdk="Microsoft.NET.Sdk">
6+
<PropertyGroup>
7+
<TargetFrameworks>net8.0</TargetFrameworks>
8+
</PropertyGroup>
9+
10+
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Smdn.Reflection.ReverseGenerating\Smdn.Reflection.ReverseGenerating.Common.props" />
11+
12+
<PropertyGroup>
13+
<IsPackable>false</IsPackable>
14+
<VersionSuffix>private</VersionSuffix>
15+
16+
<!--
17+
To avoid cyclic references (error NU1108) when making NuGet packages,
18+
disable generating API list to prevent including the package reference to ListApi.MSBuild.Tasks.
19+
-->
20+
<APIListEnableGenerating>false</APIListEnableGenerating>
21+
</PropertyGroup>
22+
</Project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 smdn <smdn@smdn.jp>
3+
SPDX-License-Identifier: MIT
4+
-->
5+
<Project>
6+
<PropertyGroup>
7+
<VersionPrefix>1.4.0</VersionPrefix>
8+
<VersionSuffix></VersionSuffix>
9+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
10+
<NoWarn>CS1591;$(NoWarn)</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
11+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
12+
<!-- trimming options -->
13+
<PublishTrimmed>false</PublishTrimmed>
14+
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
15+
</PropertyGroup>
16+
17+
<PropertyGroup>
18+
<DefineConstants Condition="
19+
!(
20+
$(TargetFramework.StartsWith('net4')) Or
21+
$(TargetFramework.StartsWith('netstandard1')) Or
22+
$(TargetFramework.StartsWith('netstandard2'))
23+
)
24+
">$(DefineConstants);CAN_OVERRIDE_CUSTOMATTRIBUTEDATA_ATTRIBUTETYPE</DefineConstants>
25+
<!-- enable workaround only on .NET 6.x and .NET 7.x -->
26+
<DefineConstants Condition="
27+
$(TargetFramework.StartsWith('net6.')) or
28+
$(TargetFramework.StartsWith('net7.'))
29+
">$(DefineConstants);WORKAROUND_NULLABILITYINFO_BYREFTYPE</DefineConstants>
30+
</PropertyGroup>
31+
32+
<PropertyGroup Label="assembly attributes">
33+
<Description>The reflection library for reverse-generating declarations of types and members.</Description>
34+
<CopyrightYear>2020</CopyrightYear>
35+
</PropertyGroup>
36+
37+
<PropertyGroup Label="package properties">
38+
<PackageTags>reflection;reverse-generating;reverse-generation;generator</PackageTags>
39+
</PropertyGroup>
40+
41+
<ItemGroup>
42+
<Compile Include="$(MSBuildThisFileDirectory)Smdn.Reflection\*.cs" />
43+
<Compile Include="$(MSBuildThisFileDirectory)Smdn.Reflection.ReverseGenerating\*.cs" />
44+
<Compile Include="$(MSBuildThisFileDirectory)..\Common\System.Runtime.CompilerServices\IsExternalInit.cs" />
45+
</ItemGroup>
46+
47+
<ItemGroup>
48+
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="$(TargetFramework.StartsWith('net45')) or $(TargetFramework.StartsWith('net46')) or $(TargetFramework.StartsWith('netstandard1'))" />
49+
<PackageReference Include="Smdn.Fundamental.Reflection" Version="[3.7.0,4.0.0)" />
50+
</ItemGroup>
51+
</Project>

src/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating.csproj

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,11 @@ SPDX-License-Identifier: MIT
55
<Project Sdk="Microsoft.NET.Sdk">
66
<PropertyGroup>
77
<TargetFrameworks>net8.0;net47;net45;netstandard2.0</TargetFrameworks>
8-
<VersionPrefix>1.4.0</VersionPrefix>
9-
<VersionSuffix></VersionSuffix>
10-
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
11-
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
12-
<NoWarn>CS1591;$(NoWarn)</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
13-
<!-- trimming options -->
14-
<PublishTrimmed>false</PublishTrimmed>
15-
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
168
</PropertyGroup>
179

18-
<PropertyGroup>
19-
<DefineConstants Condition="
20-
!(
21-
$(TargetFramework.StartsWith('net4')) Or
22-
$(TargetFramework.StartsWith('netstandard1')) Or
23-
$(TargetFramework.StartsWith('netstandard2'))
24-
)
25-
">$(DefineConstants);CAN_OVERRIDE_CUSTOMATTRIBUTEDATA_ATTRIBUTETYPE</DefineConstants>
26-
<!-- enable workaround only on .NET 6.x and .NET 7.x -->
27-
<DefineConstants Condition="
28-
$(TargetFramework.StartsWith('net6.')) or
29-
$(TargetFramework.StartsWith('net7.'))
30-
">$(DefineConstants);WORKAROUND_NULLABILITYINFO_BYREFTYPE</DefineConstants>
31-
</PropertyGroup>
32-
33-
<PropertyGroup Label="assembly attributes">
34-
<Description>The reflection library for reverse-generating declarations of types and members.</Description>
35-
<CopyrightYear>2020</CopyrightYear>
36-
</PropertyGroup>
10+
<Import Project="Smdn.Reflection.ReverseGenerating.Common.props" />
3711

38-
<PropertyGroup Label="package properties">
39-
<PackageTags>reflection;reverse-generating;reverse-generation;generator</PackageTags>
12+
<PropertyGroup>
13+
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
4014
</PropertyGroup>
41-
42-
<ItemGroup>
43-
<PackageReference Include="System.ValueTuple" Version="4.5.0" Condition="$(TargetFramework.StartsWith('net45')) or $(TargetFramework.StartsWith('net46')) or $(TargetFramework.StartsWith('netstandard1'))" />
44-
<PackageReference Include="Smdn.Fundamental.Reflection" Version="[3.7.0,4.0.0)" />
45-
</ItemGroup>
46-
47-
<ItemGroup>
48-
<Compile Include="..\Common\System.Runtime.CompilerServices\IsExternalInit.cs" />
49-
</ItemGroup>
5015
</Project>

0 commit comments

Comments
 (0)