Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Resolve versions for ProjectReferences and floating package references (
Browse files Browse the repository at this point in the history
  • Loading branch information
natemcmaster authored Dec 16, 2016
1 parent 91abc3e commit 2650193
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 7 deletions.
1 change: 1 addition & 0 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PropertyGroup>
<WarningsAsErrors>true</WarningsAsErrors> <!-- make disabling warnings opt-out -->
<CustomAfterMicrosoftCommonTargets>$(MSBuildThisFileDirectory)targets\Internal.AspNetCore.Common.targets</CustomAfterMicrosoftCommonTargets>
<CustomAfterMicrosoftCommonCrossTargetingTargets>$(MSBuildThisFileDirectory)targets\Internal.AspNetCore.Common.targets</CustomAfterMicrosoftCommonCrossTargetingTargets>
</PropertyGroup>

<!-- version options -->
Expand Down
11 changes: 8 additions & 3 deletions build/targets/Internal.AspNetCore.Common.targets
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!--
Copyright (c) .NET Foundation. All rights reserved.
Licensed under the Apache License, Version 2.0.
-->
<!--
WARNING: This file is meant for building Microsoft's ASP.NET Core repos, and is not intended
for use outside of Microsoft.
-->
<Project>
<Import Project="Workarounds.targets" />

<PropertyGroup>
<_IsCrossTargeting Condition="'$(TargetFrameworks)'!='' AND '$(TargetFramework)'==''">true</_IsCrossTargeting>
</PropertyGroup>

<Import Project="Workarounds.CrossTargeting.targets" Condition="'$(_IsCrossTargeting)'=='true'" />
<Import Project="Workarounds.targets" Condition="'$(_IsCrossTargeting)'!='true'" />
</Project>
43 changes: 43 additions & 0 deletions build/targets/Workarounds.CrossTargeting.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
Copyright (c) .NET Foundation. All rights reserved.
Licensed under the Apache License, Version 2.0.
WARNING: This file is meant for building Microsoft's ASP.NET Core repos, and is not intended
for use outside of Microsoft.
-->
<Project>
<!-- workaround https://github.com/NuGet/Home/issues/4063 -->
<!-- workaround https://github.com/NuGet/Home/issues/3953 -->
<Target Name="ResolveActualPackageVersions" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_TargetFramework Include="$(TargetFrameworks)" />
</ItemGroup>

<MSBuild Projects="$(MSBuildProjectFile)"
Targets="ResolvePackageDependenciesDesignTime"
Properties="TargetFramework=%(_TargetFramework.Identity)">
<Output TaskParameter="TargetOutputs" ItemName="_DependenciesDesignTime" />
</MSBuild>

<ItemGroup>
<_Tmp Include="@(_ProjectReferences)" />
<_ProjectReferences Remove="@(_ProjectReferences)" />
<_ProjectReferences Include="@(_Tmp)">
<PackageVersion>$(Version)</PackageVersion>
</_ProjectReferences>

<_FloatingVersions Include="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
<_ResolvedFloatingVersion Include="@(_FloatingVersions)">
<ResolvedName>%(_DependenciesDesignTime.Name)</ResolvedName>
<Version>%(_DependenciesDesignTime.Version)</Version>
</_ResolvedFloatingVersion>
<_PackageReferences Remove="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
<_PackageReferences Include="@(_ResolvedFloatingVersion)" Condition="'%(Identity)'=='%(_ResolvedFloatingVersion.ResolvedName)'" />
</ItemGroup>


<Message Importance="Normal" Text="Proj: %(_ProjectReferences.FileName) %(_ProjectReferences.PackageVersion)" />
<Message Importance="Normal" Text="Pkg: %(_PackageReferences.Identity) %(_PackageReferences.Version)" />
</Target>
<!-- end workaround -->
</Project>
25 changes: 21 additions & 4 deletions build/targets/Workarounds.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<!--
Copyright (c) .NET Foundation. All rights reserved.
Licensed under the Apache License, Version 2.0.
WARNING: This file is meant for building Microsoft's ASP.NET Core repos, and is not intended
for use outside of Microsoft.
-->

<!-- this file is dedicated to working around bugs in Microsoft.NET.Sdk RC.2 release -->
<Project>
<!-- workaround https://github.com/Microsoft/vstest/issues/191 -->
Expand All @@ -8,12 +16,18 @@
<!-- end workaround -->

<!-- workaround https://github.com/NuGet/Home/issues/4063 -->
<Target Name="ResolveRestoredPackageVersions"
BeforeTargets="GenerateNuspec"
DependsOnTargets="ResolvePackageDependenciesDesignTime"
Condition="'$(TargetFramework)'!=''">
<!-- workaround https://github.com/NuGet/Home/issues/3953 -->
<Target Name="ResolveActualPackageVersions"
BeforeTargets="GenerateNuSpec"
DependsOnTargets="ResolvePackageDependenciesDesignTime">

<ItemGroup>
<_Tmp Include="@(_ProjectReferences)" />
<_ProjectReferences Remove="@(_ProjectReferences)" />
<_ProjectReferences Include="@(_Tmp)">
<PackageVersion>$(Version)</PackageVersion>
</_ProjectReferences>

<_FloatingVersions Include="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
<_ResolvedFloatingVersion Include="@(_FloatingVersions)">
<ResolvedName>%(_DependenciesDesignTime.Name)</ResolvedName>
Expand All @@ -22,6 +36,9 @@
<_PackageReferences Remove="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
<_PackageReferences Include="@(_ResolvedFloatingVersion)" Condition="'%(Identity)'=='%(_ResolvedFloatingVersion.ResolvedName)'" />
</ItemGroup>

<Message Importance="Normal" Text="Proj: %(_ProjectReferences.FileName) %(_ProjectReferences.PackageVersion)" />
<Message Importance="Normal" Text="Pkg: %(_PackageReferences.Identity) %(_PackageReferences.Version)" />
</Target>
<!-- end workaround -->

Expand Down

0 comments on commit 2650193

Please sign in to comment.