Add NuGet.BuildTasks
authorWonYoung Choi <wy80.choi@samsung.com>
Tue, 4 Oct 2016 04:24:13 +0000 (13:24 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Tue, 4 Oct 2016 04:24:13 +0000 (13:24 +0900)
Change-Id: I69625c4e5f96f4fe95de62abcaa00e311bf63350

packaging/dotnet-build-tools.spec
tasks/GBS/Tizen.CSharp.GBS.targets [moved from targets/Tizen.CSharp.GBS.targets with 100% similarity]
tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets [new file with mode: 0644]
tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props [new file with mode: 0644]
tasks/NuGet/Microsoft.NuGet.Build.Tasks.dll [new file with mode: 0644]
tasks/NuGet/Microsoft.NuGet.props [new file with mode: 0644]
tasks/NuGet/Microsoft.NuGet.targets [new file with mode: 0644]
tools/nuget/NuGet.Config [moved from nuget/NuGet.Config with 62% similarity]
tools/nuget/NuGet.exe [moved from nuget/NuGet.exe with 100% similarity, mode: 0644]
tools/nuget/nuget [new file with mode: 0755]

index 8148f20..981af69 100644 (file)
@@ -23,10 +23,23 @@ C# Deivce API with xbuild in GBS environment.
 
 %install
 # nuget
+%define NuGetDir %{_datadir}/NuGet
+mkdir -p %{buildroot}%{NuGetDir}
 mkdir -p %{buildroot}%{_bindir}
-install -p -m 755 nuget/NuGet.exe %{buildroot}%{_bindir}
-install -p -m 644 nuget/NuGet.Config %{buildroot}
-ln -s %{_bindir}/NuGet.exe %{buildroot}%{_bindir}/nuget.exe
+install -p -m 755 tools/nuget/* %{buildroot}%{NuGetDir}
+ln -s %{NuGetDir}/nuget %{buildroot}%{_bindir}/nuget
+ln -s %{NuGetDir}/NuGet.exe %{buildroot}%{_bindir}/nuget.exe
+
+# NuGet.BuildTasks
+%define XBuildDir %{_libdir}/mono/xbuild
+mkdir -p %{buildroot}%{XBuildDir}/Microsoft/NuGet
+install -p -m 644 tasks/NuGet/Microsoft.NuGet.targets %{buildroot}%{XBuildDir}/Microsoft/NuGet
+install -p -m 644 tasks/NuGet/Microsoft.NuGet.Build.Tasks.dll %{buildroot}%{XBuildDir}/Microsoft/NuGet
+install -p -m 644 tasks/NuGet/Microsoft.NuGet.props %{buildroot}%{XBuildDir}/Microsoft/NuGet
+mkdir -p %{buildroot}%{XBuildDir}/14.0/Microsoft.Common.targets/ImportBefore
+install -p -m 644 tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props %{buildroot}%{XBuildDir}/14.0/Microsoft.Common.targets/ImportBefore
+mkdir -p %{buildroot}%{XBuildDir}/14.0/Microsoft.Common.targets/ImportAfter
+install -p -m 644 tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets %{buildroot}%{XBuildDir}/14.0/Microsoft.Common.targets/ImportAfter
 
 # local nuget packages
 mkdir -p %{buildroot}/nuget
@@ -40,12 +53,13 @@ ln -s %{_datadir}/dotnet-gbs/dotnet-gbs.py %{buildroot}/%{_bindir}/dotnet-gbs
 # Targets
 %define TargetDir %{_libdir}/mono/xbuild/Tizen
 mkdir -p %{buildroot}%{TargetDir}
-install -p -m 644 targets/* %{buildroot}%{TargetDir}
+install -p -m 644 tasks/GBS/* %{buildroot}%{TargetDir}
 
 %files
 %license LICENSE
-/NuGet.Config
 %{_bindir}/*
+%{NuGetDir}/*
 %{TargetDir}/*
+%{XBuildDir}/*
 %{_datadir}/dotnet-gbs/*
 /nuget/*.nupkg
diff --git a/tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets b/tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportAfter.targets
new file mode 100644 (file)
index 0000000..72ce25d
--- /dev/null
@@ -0,0 +1,17 @@
+<!--
+***********************************************************************************************
+Microsoft.NuGet.ImportAfter.targets
+
+WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
+          created a backup copy.  Incorrect changes to this file will make it
+          impossible to load or build your projects from the command-line or the IDE.
+
+Copyright (c) .NET Foundation. All rights reserved. 
+***********************************************************************************************
+-->
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <NuGetTargets Condition="'$(NuGetTargets)'==''">$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.targets</NuGetTargets>
+  </PropertyGroup>
+  <Import Condition="Exists('$(NuGetTargets)')" Project="$(NuGetTargets)" />
+</Project>
diff --git a/tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props b/tasks/NuGet/ImportBeforeAfter/Microsoft.NuGet.ImportBefore.props
new file mode 100644 (file)
index 0000000..a34517c
--- /dev/null
@@ -0,0 +1,17 @@
+<!--
+***********************************************************************************************
+Microsoft.NuGet.ImportBefore.props
+
+WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
+          created a backup copy.  Incorrect changes to this file will make it
+          impossible to load or build your projects from the command-line or the IDE.
+
+Copyright (c) .NET Foundation. All rights reserved. 
+***********************************************************************************************
+-->
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <NuGetProps Condition="'$(NuGetProps)'==''">$(MSBuildExtensionsPath)\Microsoft\NuGet\Microsoft.NuGet.props</NuGetProps>
+  </PropertyGroup>
+  <Import Condition="Exists('$(NuGetProps)')" Project="$(NuGetProps)" />
+</Project>
diff --git a/tasks/NuGet/Microsoft.NuGet.Build.Tasks.dll b/tasks/NuGet/Microsoft.NuGet.Build.Tasks.dll
new file mode 100644 (file)
index 0000000..dd280df
Binary files /dev/null and b/tasks/NuGet/Microsoft.NuGet.Build.Tasks.dll differ
diff --git a/tasks/NuGet/Microsoft.NuGet.props b/tasks/NuGet/Microsoft.NuGet.props
new file mode 100644 (file)
index 0000000..a3b4823
--- /dev/null
@@ -0,0 +1,14 @@
+<!--
+***********************************************************************************************
+Microsoft.NuGet.props
+
+WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
+          created a backup copy.  Incorrect changes to this file will make it
+          impossible to load or build your projects from the command-line or the IDE.
+
+Copyright (c) .NET Foundation. All rights reserved. 
+***********************************************************************************************
+-->
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.props" Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.props') AND '$(IncludeNuGetImports)' != 'false'" />
+</Project>
diff --git a/tasks/NuGet/Microsoft.NuGet.targets b/tasks/NuGet/Microsoft.NuGet.targets
new file mode 100644 (file)
index 0000000..42dbc16
--- /dev/null
@@ -0,0 +1,271 @@
+<!--
+***********************************************************************************************
+Microsoft.NuGet.targets
+
+WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
+          created a backup copy.  Incorrect changes to this file will make it
+          impossible to load or build your projects from the command-line or the IDE.
+
+Copyright (c) .NET Foundation. All rights reserved. 
+***********************************************************************************************
+-->
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <UsingTask TaskName="Microsoft.NuGet.Build.Tasks.ResolveNuGetPackageAssets" AssemblyFile="Microsoft.NuGet.Build.Tasks.dll" />
+
+  <PropertyGroup Condition="'$(ProjectLockFile)' == ''">
+    <_ProjectSpecificProjectJsonFile>$(MSBuildProjectName).project.json</_ProjectSpecificProjectJsonFile>
+    <ProjectLockFile Condition="Exists('$(_ProjectSpecificProjectJsonFile)')">$(MSBuildProjectName).project.lock.json</ProjectLockFile>
+    <ProjectLockFile Condition="!Exists('$(_ProjectSpecificProjectJsonFile)')">project.lock.json</ProjectLockFile>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <ResolveNuGetPackages Condition="'$(ResolveNuGetPackages)' == '' and '$(MSBuildProjectExtension)' != '.xproj'">true</ResolveNuGetPackages>
+
+    <BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == '' and '$(TargetPlatformIdentifier)' == 'UAP'">win10</BaseNuGetRuntimeIdentifier>
+    <BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == ''">win</BaseNuGetRuntimeIdentifier>
+
+    <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>
+
+    <CopyNuGetImplementations Condition="'$(CopyNuGetImplementations)' == '' and (('$(OutputType)' != 'library' and ('$(OutputType)' != 'winmdobj' or '$(AppxPackage)' == 'true')) or '$(TargetFrameworkIdentifier)' == '.NETFramework')">true</CopyNuGetImplementations>
+    <IncludeFrameworkReferencesFromNuGet Condition="'$(IncludeFrameworkReferencesFromNuGet)' == ''">true</IncludeFrameworkReferencesFromNuGet>
+
+    <_NuGetRuntimeIdentifierPlatformTargetSuffix Condition="'$(PlatformTarget)' != '' and '$(PlatformTarget)' != 'AnyCPU'">-$(PlatformTarget.ToLower())</_NuGetRuntimeIdentifierPlatformTargetSuffix>
+    <_NuGetRuntimeIdentifierWithoutAot>$(BaseNuGetRuntimeIdentifier)$(_NuGetRuntimeIdentifierPlatformTargetSuffix)</_NuGetRuntimeIdentifierWithoutAot>
+  </PropertyGroup>
+
+  <!-- If a NuGetRuntimeIdentifier wasn't already specified, let's go generate it -->
+  <PropertyGroup Condition="'$(NuGetRuntimeIdentifier)' == '' and '$(CopyNuGetImplementations)' == 'true'">
+    <NuGetRuntimeIdentifier>$(_NuGetRuntimeIdentifierWithoutAot)</NuGetRuntimeIdentifier>
+    <NuGetRuntimeIdentifier Condition="'$(UseDotNetNativeToolchain)' == 'true'">$(_NuGetRuntimeIdentifierWithoutAot)-aot</NuGetRuntimeIdentifier>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <!-- If we are resolving from project.lock.json, we need to consider any edit to it as something that forces a rebuild -->
+    <CustomAdditionalCompileInputs Include="$(ProjectLockFile)" Condition="'$(ResolveNuGetPackages)' == 'true' and Exists('$(ProjectLockFile)')" />
+  </ItemGroup>
+
+  <PropertyGroup Condition="'$(TargetPlatformIdentifier)' == 'UAP'">
+    <_NuGetTargetFallbackMoniker>UAP,Version=v10.0</_NuGetTargetFallbackMoniker>
+    <ImplicitlyExpandTargetFramework>false</ImplicitlyExpandTargetFramework>
+    <EnableAppLocalFXWorkaround>false</EnableAppLocalFXWorkaround>
+    <UseNetNativeCustomFramework>true</UseNetNativeCustomFramework>
+  </PropertyGroup>
+
+  <!--
+    ============================================================
+                                        GetProjectsReferencingProjectJsonFiles
+    ============================================================
+  -->
+  <Target Name="GetProjectsReferencingProjectJson" DependsOnTargets="_SplitProjectReferencesByFileExistence" Returns="@(_ProjectReferencingProjectJsonFile)">
+    <ItemGroup Condition="'$(ResolveNuGetPackages)' == 'true'">
+      <_ProjectReferencingProjectJsonFile Include="$(MSBuildProjectFullPath)">
+        <ProjectReferences>@(ProjectReference)</ProjectReferences>
+        <ProjectJson>$(MSBuildProjectDirectory)\project.json</ProjectJson>
+      </_ProjectReferencingProjectJsonFile>
+    </ItemGroup>
+
+    <MSBuild
+      Projects="@(_MSBuildProjectReferenceExistent)"
+      Targets="GetProjectsReferencingProjectJson"
+      BuildInParallel="$(BuildInParallel)"
+      Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)"
+      RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
+
+      <Output TaskParameter="TargetOutputs" ItemName="_ProjectReferencingProjectJsonFile" />
+    </MSBuild>
+  </Target>
+
+  <ItemGroup>
+    <NuGetPreprocessorValue Include="rootnamespace">
+      <Value>$(RootNamespace)</Value>
+    </NuGetPreprocessorValue>
+    <NuGetPreprocessorValue Include="assemblyname">
+      <Value>$(AssemblyName)</Value>
+    </NuGetPreprocessorValue>
+    <NuGetPreprocessorValue Include="fullpath">
+      <Value>$(MSBuildProjectDirectory)</Value>
+    </NuGetPreprocessorValue>
+    <NuGetPreprocessorValue Include="outputfilename">
+      <Value>$(TargetFileName)</Value>
+    </NuGetPreprocessorValue>
+    <NuGetPreprocessorValue Include="filename">
+      <Value>$(MSBuildProjectFile)</Value>
+    </NuGetPreprocessorValue>
+  </ItemGroup>
+
+  <!--
+    ============================================================
+                                        ResolveNuGetPackageAssets
+
+    Resolve assets from consumed NuGet packages listed in the project.lock.json
+
+        [OUT]
+        @(Analyzer) - Paths to build-time diagnostic analyzers
+        @(Reference) - Paths to build-time NuGet dependencies
+        @(ReferenceCopyLocalPaths) - Paths to run-time dependencies to copy
+    ============================================================
+  -->
+  <PropertyGroup>
+    <ResolveAssemblyReferencesDependsOn>$(ResolveAssemblyReferencesDependsOn);ResolveNuGetPackageAssets</ResolveAssemblyReferencesDependsOn>
+    <PrepareResourcesDependsOn>ResolveNuGetPackageAssets;$(PrepareResourcesDependsOn)</PrepareResourcesDependsOn>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <ResolveNuGetPackageAssetsDependsOn>ResolveProjectReferences</ResolveNuGetPackageAssetsDependsOn>
+    <ResolveNuGetPackageAssetsDependsOn Condition="'$(ImplicitlyExpandTargetFramework)' == 'true'">$(ResolveNuGetPackageAssetsDependsOn);ImplicitlyExpandTargetFramework</ResolveNuGetPackageAssetsDependsOn>
+  </PropertyGroup>
+
+  <Target Name="ResolveNuGetPackageAssets" DependsOnTargets="$(ResolveNuGetPackageAssetsDependsOn)" Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
+    <!-- We need to figure out the output path of any dependent xproj projects -->
+    <MSBuild
+      Projects="@(_MSBuildProjectReferenceExistent)"
+      Targets="GetTargetDir"
+      BuildInParallel="$(BuildInParallel)"
+      Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform)"
+      RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)"
+      Condition="'%(_MSBuildProjectReferenceExistent.Extension)' == '.xproj'">
+
+      <Output TaskParameter="TargetOutputs" ItemName="_XProjTargetDirs" />
+    </MSBuild>
+
+    <!-- The items in _XProjTargetDirs have the target directories as the main itemspecs and the originating project as metadata; reverse them -->
+    <ItemGroup>
+      <ProjectReferenceCreatingPackage Include="%(_XProjTargetDirs.OriginalItemSpec)">
+        <OutputBasePath>%(_XProjTargetDirs.Identity)</OutputBasePath>
+      </ProjectReferenceCreatingPackage>
+    </ItemGroup>
+
+    <ResolveNuGetPackageAssets AllowFallbackOnTargetSelection="$(DesignTimeBuild)"
+                               ContinueOnError="$(ContinueOnError)"
+                               IncludeFrameworkReferences="$(IncludeFrameworkReferencesFromNuGet)"
+                               NuGetPackagesDirectory="$(NuGetPackagesDirectory)"
+                               RuntimeIdentifier="$(NuGetRuntimeIdentifier)"
+                               ProjectLanguage="$(Language)"
+                               ProjectLockFile="$(ProjectLockFile)"
+                               ProjectReferencesCreatingPackages="@(ProjectReferenceCreatingPackage)"
+                               ContentPreprocessorValues="@(NuGetPreprocessorValue)"
+                               ContentPreprocessorOutputDirectory="$(IntermediateOutputPath)\NuGet"
+                               TargetMonikers="$(NuGetTargetMoniker);$(_NuGetTargetFallbackMoniker)">
+
+      <Output TaskParameter="ResolvedAnalyzers" ItemName="Analyzer" />
+      <Output TaskParameter="ResolvedCopyLocalItems" ItemName="ReferenceCopyLocalPaths" />
+      <Output TaskParameter="ResolvedReferences" ItemName="_ReferencesFromNuGetPackages" />
+      <Output TaskParameter="ReferencedPackages" ItemName="ReferencedNuGetPackages" />
+      <Output TaskParameter="ContentItems" ItemName="_NuGetContentItems" />
+      <Output TaskParameter="FileWrites" ItemName="FileWrites" />
+    </ResolveNuGetPackageAssets>
+
+    <ItemGroup>
+      <!-- Remove exact references, such as if a package had a framework reference to 'System' that we already have -->
+      <Reference Remove="@(_ReferencesFromNuGetPackages)" />
+
+      <!-- Remove simple name references that are already implicitly added -->
+      <_ReferencesFromNuGetPackages Remove="%(ReferencePath.FileName)" Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetFramework'" />
+
+      <!-- Include NuGet references in the proper groups. Project-to-project references must go in the
+           _ResolvedProjectReferencePaths group which matches the behavior of the ResolveProjectReferences
+           target. This ensures that even if the assembly is missing on disk, it still makes it to the compiler. -->
+      <Reference Include="@(_ReferencesFromNuGetPackages)" Condition="'%(_ReferencesFromNuGetPackages.NuGetSourceType)' != 'Project'" />
+      <_ResolvedProjectReferencePaths Include="@(_ReferencesFromNuGetPackages)" Condition="'%(_ReferencesFromNuGetPackages.NuGetSourceType)' == 'Project'" />
+
+      <!-- Remove simple name references if we're directly providing a reference assembly to the compiler. For example,
+           consider a project with an Reference Include="System", and some NuGet package is providing System.dll -->
+      <Reference Remove="%(_ReferencesFromNuGetPackages.FileName)" Condition="'%(_ReferencesFromNuGetPackages.NuGetIsFrameworkReference)' == 'false'"/>
+    </ItemGroup>
+
+    <PropertyGroup Condition=" '$(AutoUnifyAssemblyReferences)' == 'true' ">
+      <!-- Normally Design Time Assembly Resolution (DTAR) won't consider these references.
+           Put DTAR in a mode where it will prefer the output of RAR and unify. -->
+      <DTARUseReferencesFromProject>true</DTARUseReferencesFromProject>
+    </PropertyGroup>
+
+    <!-- The items in _NuGetContentItems need to go into the appropriately-named item group, but the names depend upon the items
+         themselves. Split it apart. -->
+    <CreateItem Include="@(_NuGetContentItems)" Condition="'@(_NuGetContentItems)' != ''">
+      <Output TaskParameter="Include" ItemName="%(_NuGetContentItems.NuGetItemType)" />
+    </CreateItem>
+  </Target>
+
+  <Target Name="RuntimeImplementationProjectOutputGroup" Returns="@(RuntimeImplementationProjectOutputGroupOutput)" Condition="'$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')">
+    <!-- This output group must contain the implementation assemblies for the host (i.e. design time) environment, not the
+         target environment. Thus, we explicitly pass the RuntimeIdentifier that doesn't have the -aot suffix -->
+    <ResolveNuGetPackageAssets AllowFallbackOnTargetSelection="$(DesignTimeBuild)"
+                               NuGetPackagesDirectory="$(NuGetPackagesDirectory)"
+                               RuntimeIdentifier="$(_NuGetRuntimeIdentifierWithoutAot)"
+                               ProjectLanguage="$(Language)"
+                               ProjectLockFile="$(ProjectLockFile)"
+                               TargetMonikers="$(NuGetTargetMoniker);$(_NuGetTargetFallbackMoniker)">
+
+      <Output TaskParameter="ResolvedCopyLocalItems" ItemName="NonAheadOfTimeRuntimeImplementations" />
+    </ResolveNuGetPackageAssets>
+
+    <ItemGroup>
+      <RuntimeImplementationProjectOutputGroupOutput Include="%(NonAheadOfTimeRuntimeImplementations.Identity)">
+        <FinalOutputPath>%(NonAheadOfTimeRuntimeImplementations.FullPath)</FinalOutputPath>
+        <TargetPath>%(NonAheadOfTimeRuntimeImplementations.FullPath)</TargetPath>
+      </RuntimeImplementationProjectOutputGroupOutput>
+    </ItemGroup>
+  </Target>
+
+  <!--
+    ============================================================
+            Framework injection into mixed-target applications
+    ============================================================
+  -->
+  <PropertyGroup>
+    <NuGetTargetFrameworkMonikerToInject Condition="'$(NuGetTargetFrameworkMonikerToInject)' == ''">.NETCore,Version=v5.0</NuGetTargetFrameworkMonikerToInject>
+    <NuGetTargetMonikerToInject Condition="'$(NuGetTargetMonikerToInject)' == ''">.NETCore,Version=v5.0</NuGetTargetMonikerToInject>
+    <_ComputeNetCoreFrameworkInjectionParametersBeforeTargets Condition="'$(AppxPackage)' == 'true' and '$(TargetPlatformIdentifier)' == 'UAP'">BeforeGenerateProjectPriFile</_ComputeNetCoreFrameworkInjectionParametersBeforeTargets>
+  </PropertyGroup>
+
+  <Target Name="ComputeNetCoreFrameworkInjectionParameters" BeforeTargets="$(_ComputeNetCoreFrameworkInjectionParametersBeforeTargets)" DependsOnTargets="_AddUnionWinmd" Condition="'$(_ComputeNetCoreFrameworkInjectionParametersBeforeTargets)' != ''">
+    <PropertyGroup>
+      <_PackagingOutputsIncludesFramework Condition="'%(PackagingOutputs.FileName)%(PackagingOutputs.Extension)' == 'System.Runtime.dll'">true</_PackagingOutputsIncludesFramework>
+      <_AppContainsManagedCodeForInjection Condition="'%(PackagingOutputs.Identity)' == '$(_TargetPlatformSdkDir)UnionMetadata\Windows.winmd'">true</_AppContainsManagedCodeForInjection>
+    </PropertyGroup>
+
+    <PropertyGroup>
+      <_NetCoreFrameworkInjectionNeeded Condition="'$(_PackagingOutputsIncludesFramework)' != 'true' and '$(_AppContainsManagedCodeForInjection)' == 'true'">true</_NetCoreFrameworkInjectionNeeded>
+    </PropertyGroup>
+  </Target>
+
+  <Target Name="InjectNetCoreFrameworkBlockIfLockFileExists" AfterTargets="ComputeNetCoreFrameworkInjectionParameters" Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and '$(ResolveNuGetPackages)' == 'true' and Exists('$(ProjectLockFile)')">
+    <Error Text="One of your dependencies requires the .NET Framework, but the .NET Framework could not be found in the NuGet packages installed in this project.  Please install the appropriate .NET Framework packages required by your dependency." />
+  </Target>
+
+  <Target Name="InjectNetCoreFramework" AfterTargets="ComputeNetCoreFrameworkInjectionParameters" Condition="'$(_NetCoreFrameworkInjectionNeeded)' == 'true' and ('$(ResolveNuGetPackages)' != 'true' or !Exists('$(ProjectLockFile)'))">
+    <GetReferenceAssemblyPaths TargetFrameworkMoniker="$(NuGetTargetFrameworkMonikerToInject)" Condition="'$(FrameworkInjectionLockFile)' == ''">
+      <Output TaskParameter="ReferenceAssemblyPaths" ItemName="_NuGetInjectionSourceDirectories" />
+    </GetReferenceAssemblyPaths>
+
+    <PropertyGroup>
+      <FrameworkInjectionLockFile Condition="'$(FrameworkInjectionLockFile)' == ''">@(_NuGetInjectionSourceDirectories->'%(Identity)\project.lock.json')</FrameworkInjectionLockFile>
+      <FrameworkInjectionPackagesDirectory Condition="'$(FrameworkInjectionPackagesDirectory)' == ''">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\NuGet\Repository', 'NETCoreSDK', null, RegistryView.Registry32, RegistryView.Default))</FrameworkInjectionPackagesDirectory>
+    </PropertyGroup>
+
+    <ResolveNuGetPackageAssets Condition="Exists('$(FrameworkInjectionLockFile)')"
+                               NuGetPackagesDirectory="$(FrameworkInjectionPackagesDirectory)"
+                               RuntimeIdentifier="$(NuGetRuntimeIdentifier)"
+                               TargetMonikers="$(NuGetTargetMonikerToInject)"
+                               ProjectLockFile="$(FrameworkInjectionLockFile)">
+
+      <Output TaskParameter="ResolvedCopyLocalItems" ItemName="_InjectNetCoreFrameworkPayload" />
+    </ResolveNuGetPackageAssets>
+
+    <PropertyGroup>
+      <_CoreRuntimePackageId Condition="'%(_InjectNetCoreFrameworkPayload.FileName)%(_InjectNetCoreFrameworkPayload.Extension)' == 'mscorlib.dll' OR '%(_InjectNetCoreFrameworkPayload.FileName)%(_InjectNetCoreFrameworkPayload.Extension)' == 'mscorlib.ni.dll'">%(_InjectNetCoreFrameworkPayload.NuGetPackageId)</_CoreRuntimePackageId>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <PackagingOutputs Include="@(_InjectNetCoreFrameworkPayload)" Condition="'%(_InjectNetCoreFrameworkPayload.NuGetPackageId)' != '$(_CoreRuntimePackageId)' or '$(UseDotNetNativeToolchain)' == 'true'">
+        <TargetPath>%(Filename)%(Extension)</TargetPath>
+        <ProjectName>$(ProjectName)</ProjectName>
+        <OutputGroup>CopyLocalFilesOutputGroup</OutputGroup>
+      </PackagingOutputs>
+    </ItemGroup>
+  </Target>
+
+  <Import Project="$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.targets" Condition="Exists('$(MSBuildProjectDirectory)\$(MSBuildProjectName).nuget.targets') AND '$(IncludeNuGetImports)' != 'false'" />
+</Project>
similarity index 62%
rename from nuget/NuGet.Config
rename to tools/nuget/NuGet.Config
index ed5910d..6ed4e83 100644 (file)
@@ -3,8 +3,5 @@
   <packageSources>
     <add key="local" value="/nuget" />
   </packageSources>
-  <config>
-    <add key="globalPackagesFolder" value="/tmp/nuget/packages" />
-  </config>
 </configuration>
 
old mode 100755 (executable)
new mode 100644 (file)
similarity index 100%
rename from nuget/NuGet.exe
rename to tools/nuget/NuGet.exe
diff --git a/tools/nuget/nuget b/tools/nuget/nuget
new file mode 100755 (executable)
index 0000000..0d69009
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+NUGET_DIR=/usr/share/NuGet
+
+CMD=$1
+
+CONFIGFILE_OPTION="-configfile $NUGET_DIR/NuGet.Config"
+
+case $CMD in
+    pack|init|add|locals|mirror|help)
+      CONFIGFILE_OPTION=""
+esac
+
+mono $NUGET_DIR/NuGet.exe $@ $CONFIGFILE_OPTION