-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
77 lines (60 loc) · 4.34 KB
/
Copy pathDirectory.Build.props
File metadata and controls
77 lines (60 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<Project>
<!--
============================================================================
VIM package version detection (repository-wide)
============================================================================
Both solutions consume private VIM NuGet packages from the local feed in nuget_local\
(registered in nuget.config). The package file names carry the version, so this file
reads the version off disk and the projects pin their PackageReference to it exactly,
for example "[1.5.3]".
WHY PIN INSTEAD OF FLOAT (e.g. "1.5.*")?
A floating version evaluates to the same text on every build. NuGet therefore sees an
unchanged project spec, skips the restore, and keeps the package it resolved before.
Dropping a newer patch build into nuget_local\ then has no effect until you force a
restore. An exact version read from the folder changes that text, which makes NuGet do
a real restore.
The square brackets matter: NuGet reads Version="1.5.3" as "1.5.3 or higher", but
Version="[1.5.3]" as "exactly 1.5.3".
LIMITATION - ONE VERSION AT A TIME:
MSBuild cannot sort version numbers during evaluation, so this cannot pick the highest
of several packages. Keep exactly one version of each VIM package in nuget_local\. The
ValidateVimLocalFeed target below stops the build if it finds more than one.
-->
<PropertyGroup Label="VIM local feed">
<VimLocalFeed>$(MSBuildThisFileDirectory)nuget_local\</VimLocalFeed>
</PropertyGroup>
<!--
Vim.Sdk.Standalone.1.5.3.nupkg -> $(VimSdkVersion) == "1.5.3"
NOTE: $(VimSdkVersion) is NOT always the same as the Vim.Revit.Core version suffix.
Vim.Sdk.Standalone 1.4.3.2 shipped alongside Vim.Revit.Core 2020.1.4.3, because NuGet
allows at most four version parts and the year already takes one. The Revit exporter
therefore detects its own version in
"VIM Revit Custom Exporter\Custom.Exporter\Directory.Build.props".
-->
<PropertyGroup Label="Vim.Sdk.Standalone version detection">
<_VimSdkPackageFiles Condition="Exists('$(VimLocalFeed)')">$([System.IO.Directory]::GetFiles('$(VimLocalFeed)', 'Vim.Sdk.Standalone.*.nupkg'))</_VimSdkPackageFiles>
<VimSdkVersion>$([System.Text.RegularExpressions.Regex]::Match('$(_VimSdkPackageFiles)', 'Vim\.Sdk\.Standalone\.(\d+(?:\.\d+)+)\.nupkg').Groups[1].Value)</VimSdkVersion>
</PropertyGroup>
<!--
Replaces NuGet's NU1101/NU1604 errors with a message that names the missing file and the
folder to put it in. This target runs during restore (CollectPackageReferences) and
during build. $(YearVersion) is read here rather than above because targets run after
evaluation, when the Revit exporter's Directory.Build.props has already computed it.
-->
<Target Name="ValidateVimLocalFeed" BeforeTargets="CollectPackageReferences;Build">
<ItemGroup>
<_VimSdkFeedFile Include="$(VimLocalFeed)Vim.Sdk.Standalone.*.nupkg" />
<_VimSdkPackageRef Include="@(PackageReference)" Condition="'%(Identity)' == 'Vim.Sdk.Standalone'" />
<_VimRevitCoreFeedFile Include="$(VimLocalFeed)Vim.Revit.Core.$(YearVersion).*.nupkg" />
<_VimRevitCorePackageRef Include="@(PackageReference)" Condition="'%(Identity)' == 'Vim.Revit.Core'" />
</ItemGroup>
<Error Condition="'@(_VimSdkPackageRef)' != '' And '@(_VimSdkFeedFile)' == ''"
Text="No Vim.Sdk.Standalone.*.nupkg was found in '$(VimLocalFeed)'. Copy the VIM SDK package into that folder. See CLAUDE.md." />
<Error Condition="'@(_VimSdkPackageRef)' != '' And @(_VimSdkFeedFile->Count()) > 1"
Text="Found @(_VimSdkFeedFile->Count()) Vim.Sdk.Standalone packages in '$(VimLocalFeed)': @(_VimSdkFeedFile->'%(Filename)', ', '). Version detection needs exactly one. Remove the older packages." />
<Error Condition="'@(_VimRevitCorePackageRef)' != '' And '@(_VimRevitCoreFeedFile)' == ''"
Text="No Vim.Revit.Core.$(YearVersion).*.nupkg was found in '$(VimLocalFeed)'. Copy the Revit $(YearVersion) package into that folder. See CLAUDE.md." />
<Error Condition="'@(_VimRevitCorePackageRef)' != '' And @(_VimRevitCoreFeedFile->Count()) > 1"
Text="Found @(_VimRevitCoreFeedFile->Count()) Vim.Revit.Core.$(YearVersion) packages in '$(VimLocalFeed)': @(_VimRevitCoreFeedFile->'%(Filename)', ', '). Version detection needs exactly one. Remove the older packages." />
</Target>
</Project>