Skip to content

Commit 4af94e7

Browse files
committed
CPM: rework package management to avoid package locking...
- avoid scattered lock files in multiple submodules. - use'zou nupkg -h' for more info.
1 parent 6b6a222 commit 4af94e7

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
lines changed

Directory.Build.Default.props

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@
9696
<Message Importance="high" Text=" " />
9797
</Target>
9898

99-
<Target Name="TraceDirectoryBuildDefaultProps"
100-
Condition="'$(ZouTrace)' == 'true' Or '$(ZouDirectoryBuild)' == 'true'">
101-
<Message Importance="high" Text="zou/Directory.Build.Default.props [$(MSBuildProjectFile)]" />
102-
<Message Importance="high" Text="---------------------------------" />
99+
<Target Name="TraceDirectoryBuildDefaultProps" Condition="'$(ZouTrace)' == 'true' Or '$(ZouDirectoryBuild)' == 'true'">
100+
<Message Importance="high" Text="$(T0)$(MSBuildThisFile) ($(MSBuildProjectFile))$(NC)" />
103101
<Message Importance="high" Text="LangVersion = $(LangVersion)" />
104102
<Message Importance="high" Text="RazorLangVersion = $(RazorLangVersion)" />
105103
<Message Importance="high" Text="Deterministic = $(Deterministic)" />

Directory.Build.Default.targets

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,11 @@
3232
<RepositoryUrl Condition="'$(RepositoryUrl)' == '' And '$(PackageProjectUrl)' != ''">$(PackageProjectUrl).$(RepositoryType)</RepositoryUrl>
3333
</PropertyGroup>
3434

35-
<!-- Nuget packages restore and locking -->
35+
<!-- Nuget packages restore -->
3636
<PropertyGroup>
37-
<!-- Avoid creating packages lock file from inside Visual Studio (OutputType is modified by VS for projects referencing test frameworks) -->
38-
<RestorePackagesWithLockFile Condition="'$(BuildingInsideVisualStudio)' != '' And !Exists('$(ProjectDir)packages.lock.json')">false</RestorePackagesWithLockFile>
39-
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == '' And Exists('$(ProjectDir)packages.lock.json')">true</RestorePackagesWithLockFile>
40-
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == '' And '$(CentralPackageFloatingVersionsEnabled)' == 'true' And $(OutputType.EndsWith('Exe'))">true</RestorePackagesWithLockFile>
41-
<RestorePackagesWithLockFile Condition="'$(RestorePackagesWithLockFile)' == ''">false</RestorePackagesWithLockFile>
42-
43-
<!-- Compute TFM used for package restore conditions (see Directory.Packages.default.props) -->
44-
<TFM>$(TargetFramework)</TFM>
45-
<TFM Condition="$(TargetFramework.StartsWith('netstandard'))">$(CoreTargetFramework)</TFM>
37+
<!-- Compute CpmTFM used for package restore conditions (see Directory.Packages.Floating.props) -->
38+
<CpmTFM>$(TargetFramework)</CpmTFM>
39+
<CpmTFM Condition="$(TargetFramework.StartsWith('netstandard'))">$(CoreTargetFramework)</CpmTFM>
4640
</PropertyGroup>
4741

4842
<!-- Disable some warnings -->

Directory.Packages.Default.props

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
<Project>
2-
<Import Project="Directory.Packages.Floating.props" />
2+
<PropertyGroup>
3+
<CpmTFM>$(TargetFramework)</CpmTFM>
4+
<CpmTFM Condition="$(TargetFramework.StartsWith('netstandard'))">$(CoreTargetFramework)</CpmTFM>
5+
<CpmVer>$([MSBuild]::GetTargetFrameworkVersion('$(CpmTFM)', 1))</CpmVer>
6+
<CpmId Condition="'$(CpmId)'== ''">net$(CpmVer)</CpmId>
7+
<CpmPath>$(MSBuildThisFileDirectory)Directory.Packages.$(CpmId).props</CpmPath>
8+
<CpmPath Condition="!Exists('$(CpmPath)')">$(MSBuildThisFileDirectory)Directory.Packages.Floating.props</CpmPath>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
13+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
14+
</PropertyGroup>
15+
16+
<Import Project="$(CpmPath)" />
17+
18+
<Target Name="TraceDirectoryPackagesDefault" BeforeTargets="CollectPackageReferences" Condition="'$(TraceCpm)' != ''">
19+
<Message Importance="high" Text="$(T0)$(MSBuildThisFile) ($(MSBuildProjectFile))$(NC)" />
20+
21+
<!--<ItemGroup>
22+
<CpmFile
23+
Include="$(MSBuildThisFileDirectory)Directory.Packages.*.props"
24+
Exclude="$(MSBuildThisFileDirectory)Directory.Packages.Default.props;$(MSBuildThisFileDirectory)Directory.Packages.Floating.props" />
25+
</ItemGroup>
26+
<LogItems Items="@(CpmFile)" AllMetadata="false" />
27+
<Message Importance="high" Text=" " />-->
28+
29+
<Message Importance="high" Text="CpmTFM = $(CpmTFM)" />
30+
<Message Importance="high" Text="CpmVer = $(CpmVer)" />
31+
<Message Importance="high" Text="CpmId = $(CpmId)" />
32+
<Message Importance="high" Text="CpmPath = $(CpmPath)" />
33+
<Message Importance="high" Text=" " />
34+
</Target>
335
</Project>

Directory.Packages.Floating.props

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ Lock files can be updated by using the '——force-evaluate' option.
2525

2626
<Project>
2727
<PropertyGroup>
28-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
29-
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
3028
<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
3129
</PropertyGroup>
3230

@@ -47,7 +45,7 @@ Lock files can be updated by using the '——force-evaluate' option.
4745
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.*" /> <!-- netstandard2.0 -->
4846
</ItemGroup>
4947

50-
<!-- netstandard or TFM >= net6 -->
48+
<!-- netstandard or CpmTFM >= net6 -->
5149
<ItemGroup>
5250
<PackageVersion Include="Autofac" Version="8.2.*" /> <!-- netstandard, net6, net8 -->
5351
<PackageVersion Include="Azure.Identity" Version="1.13.*" /> <!-- netstandard -->
@@ -362,8 +360,8 @@ Lock files can be updated by using the '——force-evaluate' option.
362360
<PackageVersion Include="ZXing.Net" Version="0.16.*" /> <!-- netstandard, * -->
363361
</ItemGroup>
364362

365-
<!-- TFM >= net8 but still undefined -->
366-
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TFM)', 'net8'))">
363+
<!-- CpmTFM >= net8 but still undefined -->
364+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(CpmTFM)', 'net8'))">
367365
<PackageVersion Include="Epsitec.Mailer.Core" Version="2.9.*" /> <!-- net8 ONLY -->
368366
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.*" /> <!-- net8 ONLY -->
369367
</ItemGroup>
@@ -378,8 +376,8 @@ Lock files can be updated by using the '——force-evaluate' option.
378376
<PackageVersion Update="Microsoft.Extensions.ObjectPool" Version="8.0.*" /> <!-- netstandard, net8 -->
379377
</ItemGroup>
380378

381-
<!-- TFM >= net8 -->
382-
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TFM)', 'net8'))">
379+
<!-- CpmTFM >= net8 -->
380+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(CpmTFM)', 'net8'))">
383381
<PackageVersion Update="Dapper" Version="2.1.*" /> <!-- netstandard, net8 -->
384382
<PackageVersion Update="DocumentFormat.OpenXml" Version="3.3.*" /> <!-- netstandard, net8 -->
385383
<PackageVersion Update="EFCore.NamingConventions" Version="9.0.*" /> <!-- net8 -->
@@ -500,8 +498,8 @@ Lock files can be updated by using the '——force-evaluate' option.
500498
<PackageVersion Update="TinyCsvParser" Version="2.7.*" /> <!-- netstandard, net8 -->
501499
</ItemGroup>
502500

503-
<!-- TFM >= net9 -->
504-
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TFM)', 'net9'))">
501+
<!-- CpmTFM >= net9 -->
502+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(CpmTFM)', 'net9'))">
505503
<PackageVersion Update="Microsoft.AspNetCore.OpenApi" Version="9.0.*" /> <!-- net9 -->
506504

507505
<PackageVersion Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.*" /> <!-- net9 -->
@@ -556,8 +554,8 @@ Lock files can be updated by using the '——force-evaluate' option.
556554
<PackageVersion Update="Toolbelt.Blazor.I18nText" Version="14.0.*" /> <!-- netstandard, net6 -->
557555
</ItemGroup>
558556

559-
<!-- Problematic packages (TFM <= net6) -->
560-
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('net6', '$(TFM)'))">
557+
<!-- Problematic packages (CpmTFM <= net6) -->
558+
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('net6', '$(CpmTFM)'))">
561559

562560
<!-- Version 2.3.* DOES NOT SUPPORT net6 due to Microsoft.AspNetCore.Localization 2.3.0 -> Microsoft.Extensions.Localization.Abstractions (>= 8.0.11) -->
563561
<PackageVersion Update="Microsoft.AspNetCore.Localization" Version="2.1.*" /> <!-- netstandard -->

0 commit comments

Comments
 (0)