|
| 1 | +<Project> |
| 2 | + |
| 3 | + <PropertyGroup> |
| 4 | + <AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(Configuration)' == 'Debug'">false</AutomaticVersionRangesEnabled> |
| 5 | + <AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(IsPackable)' == 'false'">false</AutomaticVersionRangesEnabled> |
| 6 | + <AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(ManagePackageVersionsCentrally)' == 'true'">false</AutomaticVersionRangesEnabled> |
| 7 | + <AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == ''">true</AutomaticVersionRangesEnabled> |
| 8 | + </PropertyGroup> |
| 9 | + |
| 10 | + <UsingTask TaskName="ConvertToVersionRange" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> |
| 11 | + <Task> |
| 12 | + <Code Source="$(MSBuildThisFileDirectory)ConvertToVersionRange.cs" /> |
| 13 | + </Task> |
| 14 | + </UsingTask> |
| 15 | + |
| 16 | + <Target Name="ConvertProjectReferenceVersionsToVersionRanges" AfterTargets="_GetProjectReferenceVersions" Condition="'$(AutomaticVersionRangesEnabled)' == 'true'"> |
| 17 | + <PropertyGroup> |
| 18 | + <NumberOfProjectReferences>@(_ProjectReferencesWithVersions->Count())</NumberOfProjectReferences> |
| 19 | + </PropertyGroup> |
| 20 | + <ConvertToVersionRange Condition="$(NumberOfProjectReferences) > 0" References="@(_ProjectReferencesWithVersions)" VersionProperty="ProjectVersion"> |
| 21 | + <Output TaskParameter="ReferencesWithVersionRanges" ItemName="_ProjectReferencesWithVersionRanges" /> |
| 22 | + </ConvertToVersionRange> |
| 23 | + <ItemGroup Condition="$(NumberOfProjectReferences) > 0"> |
| 24 | + <_ProjectReferencesWithVersions Remove="@(_ProjectReferencesWithVersions)" /> |
| 25 | + <_ProjectReferencesWithVersions Include="@(_ProjectReferencesWithVersionRanges)" /> |
| 26 | + </ItemGroup> |
| 27 | + </Target> |
| 28 | + |
| 29 | + <Target Name="ConvertPackageReferenceVersionsToVersionRanges" BeforeTargets="CollectPackageReferences" Condition="'$(AutomaticVersionRangesEnabled)' == 'true'"> |
| 30 | + <PropertyGroup> |
| 31 | + <NumberOfPackageReferences>@(PackageReference->Count())</NumberOfPackageReferences> |
| 32 | + </PropertyGroup> |
| 33 | + <ConvertToVersionRange Condition="$(NumberOfPackageReferences) > 0" References="@(PackageReference)" VersionProperty="Version"> |
| 34 | + <Output TaskParameter="ReferencesWithVersionRanges" ItemName="_PackageReferencesWithVersionRanges" /> |
| 35 | + </ConvertToVersionRange> |
| 36 | + <ItemGroup Condition="$(NumberOfPackageReferences) > 0"> |
| 37 | + <PackageReference Remove="@(PackageReference)" /> |
| 38 | + <PackageReference Include="@(_PackageReferencesWithVersionRanges)" /> |
| 39 | + </ItemGroup> |
| 40 | + </Target> |
| 41 | + |
| 42 | +</Project> |
0 commit comments