You've already forked linux-packaging-mono
189 lines
13 KiB
XML
Executable File
189 lines
13 KiB
XML
Executable File
<?xml version="1.0" encoding="utf-8"?>
|
|
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<UsingTask TaskName="PrereleaseResolveNuGetPackageAssets" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
|
|
<UsingTask TaskName="ValidateProjectDependencyVersions" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
|
|
<UsingTask TaskName="IsRestoreRequired" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
|
|
|
|
<PropertyGroup>
|
|
<ProjectJson Condition="'$(ProjectJson)'=='' and Exists('$(MSBuildProjectDirectory)/project.json')">$(MSBuildProjectDirectory)/project.json</ProjectJson>
|
|
<ProjectLockJson Condition="Exists('$(ProjectJson)') and '$(ProjectLockJson)'==''">$(MSBuildProjectDirectory)/project.lock.json</ProjectLockJson>
|
|
<ResolveNugetProjectFile Condition="'$(ResolveNugetProjectFile)' == ''">$(MSBuildProjectFullPath)</ResolveNugetProjectFile>
|
|
<RestorePackages Condition="'$(RestorePackages)'!='false' and Exists('$(ProjectJson)') and '$(DesignTimeBuild)' != 'true'">true</RestorePackages>
|
|
<PrereleaseResolveNuGetPackages Condition="'$(PrereleaseResolveNuGetPackages)'!='false' and Exists('$(ProjectJson)')">true</PrereleaseResolveNuGetPackages>
|
|
|
|
<!--
|
|
For now, prevent built-in task (if available) from running.
|
|
More changes are needed to light up on their availability
|
|
and use them instead of what we have here. See buildtools
|
|
issue #192.
|
|
-->
|
|
<ResolveNugetPackages>false</ResolveNugetPackages>
|
|
</PropertyGroup>
|
|
|
|
<!-- Restoring packages during a background (designtime) build will cause VS 2015 (v14) to get into an endless loop of resolving references. -->
|
|
<Target Name="RestorePackages"
|
|
BeforeTargets="ResolveNuGetPackages;ValidatePackageVersions"
|
|
Condition="'$(RestorePackages)'=='true' and !('$(VSDesignTimeBuild)'=='true' and '$(VisualStudioVersion)' >= '14.0')">
|
|
|
|
<Error Condition="'$(DnuRestoreCommand)'=='' and Exists('$(ProjectJson)')" Text="RestorePackages target needs a predefined DnuRestoreCommand property set in order to restore $(ProjectJson)" />
|
|
|
|
<IsRestoreRequired ProjectJsons="$(ProjectJson)" PackagesFolder="$(PackagesDir)">
|
|
<Output TaskParameter="RestoreRequired" PropertyName="RestoreRequired" />
|
|
</IsRestoreRequired>
|
|
|
|
<Exec Condition="Exists('$(ProjectJson)') AND '$(RestoreRequired)' == 'true'" Command="$(DnuRestoreCommand) "$(ProjectJson)"" StandardOutputImportance="Low" CustomErrorRegularExpression="^Unable to locate .*" />
|
|
|
|
<!-- if lock file exists be sure to update timestamp otherwise we could get in a state of aways calling restore but the lock file not being updated -->
|
|
<Touch Condition="Exists('$(ProjectLockJson)') AND '$(RestoreRequired)' == 'true'" Files="$(ProjectLockJson)" />
|
|
</Target>
|
|
|
|
<ItemGroup Condition="'$(ResolvePackages)'=='true' or '$(PrereleaseResolveNuGetPackages)'=='true'">
|
|
<CustomAdditionalCompileInputs Condition="Exists('$(ProjectJson)')" Include="$(ProjectJson)" />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<ResolveAssemblyReferencesDependsOn>
|
|
$(ResolveAssemblyReferencesDependsOn);
|
|
ResolveNuGetPackages;
|
|
ValidatePackageVersions;
|
|
</ResolveAssemblyReferencesDependsOn>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<!-- temporarily accept the old name NuGetTargetFrameworkMoniker until all projects are moved forward -->
|
|
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == ''">$(NuGetTargetFrameworkMoniker)</NuGetTargetMoniker>
|
|
<UseTargetPlatformAsNuGetTargetMoniker Condition="'$(UseTargetPlatformAsNuGetTargetMoniker)' == '' AND '$(TargetFrameworkMoniker)' == '.NETCore,Version=v5.0'">true</UseTargetPlatformAsNuGetTargetMoniker>
|
|
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == '' AND '$(UseTargetPlatformAsNuGetTargetMoniker)' == 'true'">$(TargetPlatformIdentifier),Version=v$([System.Version]::Parse('$(TargetPlatformMinVersion)').ToString(3))</NuGetTargetMoniker>
|
|
<NuGetTargetMoniker Condition="'$(NuGetTargetMoniker)' == '' AND '$(UseTargetPlatformAsNuGetTargetMoniker)' != 'true'">$(TargetFrameworkMoniker)</NuGetTargetMoniker>
|
|
<BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == '' and '$(TargetPlatformIdentifier)' == 'UAP'">win10</BaseNuGetRuntimeIdentifier>
|
|
<BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == ''">win</BaseNuGetRuntimeIdentifier>
|
|
<CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == '' and '$(OutputType)' != 'library' and ('$(OutputType)' != 'winmdobj' or '$(AppxPackage)' == 'true')">true</CopyNuGetImplementations>
|
|
</PropertyGroup>
|
|
|
|
<!-- If a RuntimeIndentifier wasn't already specified, let's go generate it -->
|
|
<PropertyGroup Condition="'$(NuGetRuntimeIdentifier)' == '' and '$(CopyNuGetImplementations)' == 'true'">
|
|
<_NuGetRuntimeIdentifierWithoutAot>$(BaseNuGetRuntimeIdentifier)-$(PlatformTarget.ToLower())</_NuGetRuntimeIdentifierWithoutAot>
|
|
<NuGetRuntimeIdentifier>$(_NuGetRuntimeIdentifierWithoutAot)</NuGetRuntimeIdentifier>
|
|
<NuGetRuntimeIdentifier Condition="'$(UseDotNetNativeToolchain)' == 'true'">$(_NuGetRuntimeIdentifierWithoutAot)-aot</NuGetRuntimeIdentifier>
|
|
</PropertyGroup>
|
|
|
|
<!-- Some projects want to explicitly use no runtime identifier, and do not want to receive any default value provided by other targets. -->
|
|
<PropertyGroup Condition="'$(NuGetRuntimeIdentifier)' == 'None'">
|
|
<NuGetRuntimeIdentifier></NuGetRuntimeIdentifier>
|
|
</PropertyGroup>
|
|
|
|
<Target Name="ResolveNuGetPackages"
|
|
Condition="'$(PrereleaseResolveNuGetPackages)'=='true'"
|
|
DependsOnTargets="$(ResolveNugetPackagesDependsOn)">
|
|
|
|
<PrereleaseResolveNuGetPackageAssets Condition="Exists('$(ProjectLockJson)')"
|
|
AllowFallbackOnTargetSelection="true"
|
|
IncludeFrameworkReferences="false"
|
|
NuGetPackagesDirectory="$(PackagesDir)"
|
|
RuntimeIdentifier="$(NuGetRuntimeIdentifier)"
|
|
ProjectLanguage="$(Language)"
|
|
ProjectLockFile="$(ProjectLockJson)"
|
|
TargetMonikers="$(NuGetTargetMoniker)">
|
|
<Output TaskParameter="ResolvedAnalyzers" ItemName="Analyzer" />
|
|
<Output TaskParameter="ResolvedReferences" ItemName="_ReferenceFromPackage" />
|
|
<Output TaskParameter="ResolvedCopyLocalItems" ItemName="_ReferenceCopyLocalPathsFromPackage" />
|
|
<Output TaskParameter="ReferencedPackages" ItemName="ReferencedNuGetPackages" />
|
|
</PrereleaseResolveNuGetPackageAssets>
|
|
|
|
<!-- We may have package references that we want to replace with project references -->
|
|
<ItemGroup>
|
|
<!-- Intersect project-refs with package-refs.
|
|
Project refs may be in _ResolvedProjectReferencePaths or Reference items.
|
|
Copy local may be in _ResolvedProjectReferencePaths or ReferenceCopyLocalPaths.
|
|
Copy local items may also be in any item like Content but we currently don't strip those.-->
|
|
<_ReferenceFileNamesToRemove Include="@(_ReferenceFromPackage)" Condition="'@(_ResolvedProjectReferencePaths->'%(FileName)%(Extension)')' == '%(FileName)%(Extension)'" />
|
|
<_ReferenceFileNamesToRemove Include="@(_ReferenceFromPackage)" Condition="'@(Reference->'%(FileName)%(Extension)')' == '%(FileName)%(Extension)'" />
|
|
|
|
<!-- If local copy is disabled remove all references, otherwise remove only project refrerences -->
|
|
<_ReferenceCopyLocalPathsFileNamesToRemove Include="@(_ReferenceCopyLocalPathsFromPackage)" Condition="'$(DisableReferenceCopyLocal)' == 'true' OR '@(_ResolvedProjectReferencePaths->'%(FileName)%(Extension)')' == '%(FileName)%(Extension)'" />
|
|
<_ReferenceCopyLocalPathsFileNamesToRemove Include="@(_ReferenceCopyLocalPathsFromPackage)" Condition="'$(DisableReferenceCopyLocal)' == 'true' OR '@(ReferenceCopyLocalPaths->'%(FileName)%(Extension)')' == '%(FileName)%(Extension)'" />
|
|
|
|
<!-- strip from the resolved package output -->
|
|
<_ReferenceFromPackage Remove="@(_ReferenceFileNamesToRemove)" />
|
|
<_ReferenceCopyLocalPathsFromPackage Remove="@(_ReferenceCopyLocalPathsFileNamesToRemove)" />
|
|
|
|
<!-- add the filtered resolved package output -->
|
|
<Reference Include="@(_ReferenceFromPackage)" />
|
|
<ReferenceCopyLocalPaths Include="@(_ReferenceCopyLocalPathsFromPackage)" />
|
|
</ItemGroup>
|
|
|
|
<Message Text="Excluding @(_ReferenceFileNamesToRemove);@(_ReferenceCopyLocalPathsFileNamesToRemove) from package references since the same file is provided by a project reference."
|
|
Condition="'@(_ReferenceFileNamesToRemove)' != '' or '@(_ReferenceCopyLocalPathsFileNamesToRemove)' != ''"/>
|
|
</Target>
|
|
|
|
<Target Name="RemoveTransitiveCompileReferences"
|
|
AfterTargets="ResolveNuGetPackages">
|
|
<ItemGroup Condition="'$(OmitTransitiveCompileReferences)' == 'true'">
|
|
<!-- get all references from nuget packages as ID so that we can substract the direct ref IDs-->
|
|
<_ReferenceAsPackageId Include="@(Reference->'%(NuGetPackageId)')" Condition="'%(Reference.NuGetPackageId)' != ''">
|
|
<OriginalIdentity>%(Identity)</OriginalIdentity>
|
|
</_ReferenceAsPackageId>
|
|
|
|
<!-- Indirect references are any references whose PackageId isn't in the direct reference set: ReferencedNuGetPackages -->
|
|
<_IndirectReferenceAsPackageId Include="@(_ReferenceAsPackageId)" Exclude="@(ReferencedNuGetPackages)"/>
|
|
|
|
<!-- Transform back to original -->
|
|
<IndirectReference Include="@(_IndirectReferenceAsPackageId->'%(OriginalIdentity)')" />
|
|
|
|
<Reference Remove="@(IndirectReference)"/>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="ValidatePackageVersions"
|
|
Condition="'$(RestorePackages)'=='true' and '$(ValidatePackageVersions)'=='true' and Exists('$(ProjectJson)')">
|
|
<ValidateProjectDependencyVersions ProjectJsons="$(ProjectJson)"
|
|
ProhibitFloatingDependencies="$(ProhibitFloatingDependencies)"
|
|
ValidationPatterns="@(ValidationPattern)" />
|
|
</Target>
|
|
|
|
<Target Name="FilterTargetingPackResolvedNugetPackages"
|
|
Condition="'$(SkipFilterTargetingPackResolvedNugetPackages)' != 'true'"
|
|
AfterTargets="ResolveNuGetPackages" >
|
|
<PropertyGroup>
|
|
<_TargetingPackPrefix>Microsoft.TargetingPack</_TargetingPackPrefix>
|
|
<TargetingPackReferenceCoreAssembly Condition="'$(TargetingPackReferenceCoreAssembly)' == '' and '%(TargetingPackReference.Identity)' == 'System.Private.CoreLib'">System.Private.CoreLib</TargetingPackReferenceCoreAssembly>
|
|
<TargetingPackReferenceCoreAssembly Condition="'$(TargetingPackReferenceCoreAssembly)' == ''">mscorlib</TargetingPackReferenceCoreAssembly>
|
|
|
|
<!--
|
|
S.P.CoreLib is generally architecture specific so disable the msbuild warning about
|
|
referencing it from an MSIL project.
|
|
-->
|
|
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch Condition="'$(TargetingPackReferenceCoreAssembly)' == 'System.Private.CoreLib'">None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
Add the mscorlib and windows to the reference set by default to avoid a lot of duplication in projects
|
|
They only act as a filter so if they aren't present in the packages references it will not impact anything.
|
|
-->
|
|
<ItemGroup Condition="'$(ExcludeDefaultTargetingPackReferences)' != 'true'">
|
|
<TargetingPackReference Include="$(TargetingPackReferenceCoreAssembly)" Condition="'$(TargetingPackReferenceCoreAssembly)' != ''" />
|
|
<TargetingPackReference Include="Windows" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<!-- Filter out all references coming out of the targeting pack packages except for TargetingPackReferences -->
|
|
<ResolvedTargetingPackReference Include="@(Reference)"
|
|
Condition="$([System.String]::new('%(Reference.NuGetPackageId)').StartsWith('$(_TargetingPackPrefix)'))" />
|
|
<ResolvedTargetingPackReferenceFilename Include="@(ResolvedTargetingPackReference -> '%(Filename)')">
|
|
<OriginalIdentity>%(Identity)</OriginalIdentity>
|
|
</ResolvedTargetingPackReferenceFilename>
|
|
<ResolvedTargetingPackReferenceFilename Remove="@(TargetingPackReference)" />
|
|
<PackageReferencesToRemove Include="@(ResolvedTargetingPackReferenceFilename -> '%(OriginalIdentity)')" />
|
|
<Reference Remove="@(PackageReferencesToRemove)" />
|
|
|
|
<!-- Filter out the copy-local set of references coming from the targeting pack packages -->
|
|
<PackageCopyLocalToRemove Include="@(ReferenceCopyLocalPaths)"
|
|
Condition="$([System.String]::new('%(ReferenceCopyLocalPaths.NuGetPackageId)').StartsWith('$(_TargetingPackPrefix)'))" />
|
|
<ReferenceCopyLocalPaths Remove="@(PackageCopyLocalToRemove)" />
|
|
</ItemGroup>
|
|
|
|
<Message Importance="Low"
|
|
Text="Removed all ResolvedTagetingPackReferences that were not specified explicitly as a TargetingPackReference=[@(TargetingPackReference)]. PackageReferencesToRemove=[@(PackageReferencesToRemove)]." />
|
|
</Target>
|
|
</Project> |