Skip to content

Commit

Permalink
Fea,添加ResolveNuGetPackageAssets支持
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jun 18, 2023
1 parent 550345e commit c13f355
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 8 deletions.
15 changes: 15 additions & 0 deletions Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ MSBuild.exe "Build.proj"
Include="@(ApplicationTypeDefaultPropsPath->Remove(0, $(ApplicationTypeDefaultPropsRootPath.Length))->Replace('\Default.props','')->Replace('/Default.props',''))"/>
</ItemGroup>
<MSBuild Projects="$(MSBuildThisFileFullPath)" StopOnFirstFailure="True" Targets="CopyApplicationTypeFiles" BuildInParallel="True" Properties="CurrentApplicationType=%(ApplicationType.Identity)"/>
<!--复制Patch文件-->
<ItemGroup>
<PatchFiles Include="$(MSBuildThisFileDirectory)\Patch\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="@(PatchFiles)" DestinationFiles="$(MSBuildThisFileDirectory)\Release\VCTargets\%(RecursiveDir)%(Filename)%(Extension)" />

<!--下载NuGet还原插件-->
<DownloadFile
Condition="!Exists('$(MSBuildThisFileDirectory)Release\NuGet.zip')"
SourceUrl="https://github.com/mingkuang-Chuyu/NuGet.BuildTasks/releases/download/v1.0.0/NuGet.zip"
DestinationFolder="$(MSBuildThisFileDirectory)Release" DestinationFileName="NuGet.zip"/>
<Unzip
SourceFiles="$(MSBuildThisFileDirectory)Release\NuGet.zip"
DestinationFolder="$(MSBuildThisFileDirectory)Release\VCTargets\v170\Microsoft\NuGet"
OverwriteReadOnlyFiles="true"/>
</Target>
<Target Name="CopyApplicationTypeFiles">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftCommonProps)' == 'true' and exists('$(MSBuildThisFileDirectory)\ImportBefore')"/>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
***********************************************************************************************
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\$(VisualStudioVersion)\Microsoft.NuGet.props</NuGetProps>-->
<NuGetProps Condition="'$(NuGetProps)'==''">$(VCTargetsPath)\Microsoft\NuGet\Microsoft.NuGet.props</NuGetProps>
</PropertyGroup>
<Import Condition="Exists('$(NuGetProps)') and '$(SkipImportNuGetProps)' != 'true'" Project="$(NuGetProps)" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)\ImportAfter\*" Condition="'$(ImportUserLocationsByWildcardAfterMicrosoftCommonTargets)' == 'true' and exists('$(MSBuildThisFileDirectory)\ImportAfter')"/>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
***********************************************************************************************
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\$(VisualStudioVersion)\Microsoft.NuGet.targets</NuGetTargets>-->
<NuGetTargets Condition="'$(NuGetTargets)'==''">$(VCTargetsPath)\Microsoft\NuGet\Microsoft.NuGet.targets</NuGetTargets>

<!--为了避免修改 Microsoft.NuGet.targets,我们指定一下 NuGet必须的属性,让其正常工作。-->
<BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == '' and '$(TargetPlatformIdentifier)' == 'Linux'">linux</BaseNuGetRuntimeIdentifier>
<BaseNuGetRuntimeIdentifier Condition="'$(BaseNuGetRuntimeIdentifier)' == '' and '$(TargetPlatformIdentifier)' == 'OSX'">osx</BaseNuGetRuntimeIdentifier>

<RuntimeIdentifiers Condition="'$(RuntimeIdentifiers)' == '' and '$(BaseNuGetRuntimeIdentifier)' == 'linux'">linux;linux-x86;linux-x64;linux-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(RuntimeIdentifiers)' == '' and '$(BaseNuGetRuntimeIdentifier)' == 'osx'">osx;osx-x86;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<Import Condition="Exists('$(NuGetTargets)') and '$(SkipImportNuGetBuildTargets)' != 'true'" Project="$(NuGetTargets)" />
</Project>
12 changes: 12 additions & 0 deletions Patch/v170/Init/Default/CppCrossToolset.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--特意给工程配置 ApplicationType与ApplicationTypeRevision显得非常基类,减少一些用户配置.-->
<ApplicationType Condition="'$(ApplicationType)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">OSX</ApplicationType>
<ApplicationType Condition="'$(ApplicationType)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">Linux</ApplicationType>
<ApplicationTypeRevision Condition="'$(ApplicationTypeRevision)' == '' and '$(ApplicationType)' != ''">1.0</ApplicationTypeRevision>
<TargetLinuxPlatform Condition="'$(TargetLinuxPlatform)' == '' and '$(ApplicationType)' != ''">Generic</TargetLinuxPlatform>

<CustomBeforeMicrosoftCommonProps>$(VCTargetsPath)\Current\Imports\Microsoft.Common.Props\ImportBefore.props</CustomBeforeMicrosoftCommonProps>
<CustomAfterMicrosoftCommonTargets>$(VCTargetsPath)\Current\Microsoft.Common.Targets\ImportAfter.targets</CustomAfterMicrosoftCommonTargets>
</PropertyGroup>
</Project>
10 changes: 2 additions & 8 deletions VCTargets/v170/Microsoft.Cpp.Default.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Platform">

<!--Fix Start 特意给工程配置 ApplicationType与ApplicationTypeRevision显得非常基类,减少一些用户配置.-->
<PropertyGroup>
<ApplicationType Condition="'$(ApplicationType)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">OSX</ApplicationType>
<ApplicationType Condition="'$(ApplicationType)' == '' and '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">Linux</ApplicationType>
<ApplicationTypeRevision Condition="'$(ApplicationTypeRevision)' == '' and '$(ApplicationType)' != ''">1.0</ApplicationTypeRevision>
<TargetLinuxPlatform Condition="'$(TargetLinuxPlatform)' == '' and '$(ApplicationType)' != ''">Generic</TargetLinuxPlatform>
</PropertyGroup>
<!--Fix Start-->
<Import Condition="Exists('$(VCTargetsPath)\Init\Default')" Project="$(VCTargetsPath)\Init\Default\*.props" />
<!--Fix End-->
<PropertyGroup>
<VCTargetsPathActual>$(VCTargetsPath)</VCTargetsPathActual>
Expand Down

0 comments on commit c13f355

Please sign in to comment.