在 Target 中获取项目引用的所有依赖(dll/NuGet/Project)的路径

Posted lonelyxmas

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在 Target 中获取项目引用的所有依赖(dll/NuGet/Project)的路径相关的知识,希望对你有一定的参考价值。

原文:在 Target 中获取项目引用的所有依赖(dll/NuGet/Project)的路径

在项目编译成 dll 之前,如何分析项目的所有依赖呢?可以在在项目的 Target 中去收集项目的依赖。

本文将说明如何在 Target 中收集项目依赖的所有 dll 的文件路径。


编写 Target

<Target Name="WalterlvDemoTarget" BeforeTargets="CoreCompile">
    <Message Text="References:" />
    <Message Text="@(Reference)" />
  </Target>
  • 1
  • 2
  • 3
  • 4

这个 Target 的作用是将项目的所有 Reference 节点作为集合输出出来。然而实际上如果真的编译这个项目,会发现我们得到的结果有一些问题:

  1. 实际上其值就是写到每一个 Reference 里面的字符串的集合
    • 比如引用了 System.Xaml,那么这里就会是 System.Xaml
  2. 如果引用是通过 ProjectReference 进行的项目引用,那么这里就没有目标项目的 dll

所以,我们需要一个新的属性来查找引用的 dll。通过 研究 Microsoft.NET.Sdk 的源码,我发现有 ReferencePath 属性可以使用,于是将 Target 改为这样:

<Target Name="WalterlvDemoTarget" BeforeTargets="CoreCompile;ResolveAssemblyReference">
    <Message Text="ReferencePaths:" />
    <Message Text="@(ReferencePath)" />
  </Target>
  • 1
  • 2
  • 3
  • 4

现在得到的所有依赖字符串则没有以上的问题。

注意,我在 BeforeTargets 上增加了一个 ResolveAssemblyReference

以上 Target 的输出

引用通常很多,所以我将以上的输出单独放到这里来,避免影响到上面一节知识的阅读。

Reference 的输出

可以看到,Reference 的输出几乎就是 Reference 中写的字符串本身。

CefSharp, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86
CefSharp.Core, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86
CefSharp.WinForms, Version=57.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138, processorArchitecture=x86
Microsoft.Expression.Interactions, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.IO.Compression.FileSystem
System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
WindowsFormsIntegration
C:Userswalterlv.nugetpackageswalterlv.demopackage1.0.0.0lib
et47Walterlv.DemoPackageLibrary.dll
PresentationCore
System.ComponentModel.Composition
System.Configuration
System.Windows.Forms
WindowsBase
PresentationFramework
System.Xaml
System.ServiceModel
System
System.Data
System.Data.DataSetExtensions
System.Management
System.Net.Http
System.Runtime.Serialization
System.ServiceProcess
System.Web
System.Xml
System.Xml.Linq
System.Drawing
Microsoft.CSharp
System.Core
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

ReferencePath 的输出

可以看到,ReferencePath 则是将所有的 dll 的路径也输出了,而且即便是项目引用,项目编译好的 dll 的路径也在。

D:WalterlvDemoWalterlv.DemoCode\_ExternalsRefsCefx86CefSharp.Core.dll
D:WalterlvDemoWalterlv.DemoCode\_ExternalsRefsCefx86CefSharp.dll
D:WalterlvDemoWalterlv.DemoCode\_ExternalsRefsCefx86CefSharp.WinForms.dll
C:Userswalterlv.nugetpackageswalterlv.demopackage1.0.0.0lib
et47Walterlv.DemoPackageLibrary.dll
D:WalterlvDemoWalterlv.DemoWalterlv.Library1inDebugWalterlv.Library1.dll
D:WalterlvDemoWalterlv.DemoWalterlv.Library2inDebugWalterlv.Library2.dll
D:WalterlvDemoWalterlv.DemoWalterlv.Library3inDebugWalterlv.Library3.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5Microsoft.CSharp.dll
D:WalterlvDemoWalterlv.DemoCode\_ExternalsRefsMicrosoft.Expression.Interactions.dll
C:Userswalterlv.nugetpackageswindowsapicodepackshell1.1.0.8libNET45Microsoft.WindowsAPICodePack.dll
C:Userswalterlv.nugetpackageswindowsapicodepackshell1.1.0.8libNET45Microsoft.WindowsAPICodePack.Shell.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5mscorlib.dll
C:Userswalterlv.nugetpackages
ewtonsoft.json11.0.2lib
et45Newtonsoft.Json.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5PresentationCore.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5PresentationFramework.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.ComponentModel.Composition.dll
C:Userswalterlv.nugetpackagessystem.composition.attributedmodel1.0.31libportable-net45+win8+wp8+wpa81System.Composition.AttributedModel.dll
C:Userswalterlv.nugetpackagessystem.composition.convention1.0.31libportable-net45+win8+wp8+wpa81System.Composition.Convention.dll
C:Userswalterlv.nugetpackagessystem.composition.hosting1.0.31libportable-net45+win8+wp8+wpa81System.Composition.Hosting.dll
C:Userswalterlv.nugetpackagessystem.composition.runtime1.0.31libportable-net45+win8+wp8+wpa81System.Composition.Runtime.dll
C:Userswalterlv.nugetpackagessystem.composition.typedparts1.0.31libportable-net45+win8+wp8+wpa81System.Composition.TypedParts.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Configuration.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Core.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Data.DataSetExtensions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Data.dll
C:Userswalterlv.nugetpackagessystem.data.sqlite.core1.0.97lib
et45System.Data.SQLite.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Drawing.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.IO.Compression.FileSystem.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Management.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Net.Http.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Runtime.Serialization.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.ServiceModel.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.ServiceProcess.dll
C:Userswalterlv.nugetpackagessystem.valuetuple4.5.0
efportable-net40+sl4+win8+wp8System.ValueTuple.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Web.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Windows.Forms.dll
D:WalterlvDemoWalterlv.DemoCode\_ExternalsRefsSystem.Windows.Interactivity.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Xaml.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Xml.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Xml.Linq.dll
C:Userswalterlv.nugetpackages	exteditorplus1.0.0.903libNET45TextEditorPlus.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5WindowsBase.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5WindowsFormsIntegration.dll
C:Userswalterlv.nugetpackageswpfmediakit3.0.2.78libNET45WPFMediaKit.dll
objDebugInterop.IWshRuntimeLibrary.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Collections.Concurrent.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Collections.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ComponentModel.Annotations.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ComponentModel.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ComponentModel.EventBasedAsync.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Diagnostics.Contracts.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Diagnostics.Debug.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Diagnostics.Tools.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Diagnostics.Tracing.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Dynamic.Runtime.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Globalization.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.IO.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Linq.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Linq.Expressions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Linq.Parallel.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Linq.Queryable.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Net.NetworkInformation.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Net.Primitives.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Net.Requests.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ObjectModel.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.Emit.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.Emit.ILGeneration.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.Emit.Lightweight.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.Extensions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Reflection.Primitives.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Resources.ResourceManager.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.Extensions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.InteropServices.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.InteropServices.WindowsRuntime.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.Numerics.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.Serialization.Json.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.Serialization.Primitives.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Runtime.Serialization.Xml.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Security.Principal.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ServiceModel.Duplex.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ServiceModel.Http.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ServiceModel.NetTcp.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ServiceModel.Primitives.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.ServiceModel.Security.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Text.Encoding.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Text.Encoding.Extensions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Text.RegularExpressions.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Threading.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Threading.Tasks.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Threading.Tasks.Parallel.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Xml.ReaderWriter.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Xml.XDocument.dll
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesSystem.Xml.XmlSerializer.dll
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96

解读原因

解析引用的 dll 的路径的 Task 是 ResolveAssemblyReference,你可以在 Microsoft.NET.Sdk 文件夹 中找到它。如果想知道 Task 是什么意思,可以阅读:理解 C# 项目 csproj 文件格式的本质和编译流程

<ResolveAssemblyReference
    Assemblies="@(Reference)"
    AssemblyFiles="@(_ResolvedProjectReferencePaths);@(_ExplicitReference)"
    TargetFrameworkDirectories="@(_ReferenceInstalledAssemblyDirectory)"
    InstalledAssemblyTables="@(InstalledAssemblyTables);@(RedistList)"
    IgnoreDefaultInstalledAssemblyTables="$(IgnoreDefaultInstalledAssemblyTables)"
    IgnoreDefaultInstalledAssemblySubsetTables="$(IgnoreInstalledAssemblySubsetTables)"
    CandidateAssemblyFiles="@(Content);@(None)"
    SearchPaths="$(AssemblySearchPaths)"
    AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
    AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
    TargetProcessorArchitecture="$(ProcessorArchitecture)"
    AppConfigFile="@(_ResolveAssemblyReferencesApplicationConfigFileForExes)"
    AutoUnify="$(AutoUnifyAssemblyReferences)"
    SupportsBindingRedirectGeneration="$(GenerateBindingRedirectsOutputType)"
    IgnoreVersionForFrameworkReferences="$(IgnoreVersionForFrameworkReferences)"
    FindDependencies="$(_FindDependencies)"
    FindSatellites="$(BuildingProject)"
    FindSerializationAssemblies="$(BuildingProject)"
    FindRelatedFiles="$(BuildingProject)"
    Silent="$(ResolveAssemblyReferencesSilent)"
    TargetFrameworkVersion="$(TargetFrameworkVersion)"
    TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
    TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)"
    TargetedRuntimeVersion="$(TargetedRuntimeVersion)"
    StateFile="$(ResolveAssemblyReferencesStateFile)"
    InstalledAssemblySubsetTables="@(InstalledAssemblySubsetTables)"
    TargetFrameworkSubsets="@(_ReferenceInstalledAssemblySubsets)"
    FullTargetFrameworkSubsetNames="$(FullReferenceAssemblyNames)"
    FullFrameworkFolders="$(_FullFrameworkReferenceAssemblyPaths)"
    FullFrameworkAssemblyTables="@(FullFrameworkAssemblyTables)"
    ProfileName="$(TargetFrameworkProfile)"
    LatestTargetFrameworkDirectories="@(LatestTargetFrameworkDirectories)"
    CopyLocalDependenciesWhenParentReferenceInGac="$(CopyLocalDependenciesWhenParentReferenceInGac)"
    DoNotCopyLocalIfInGac="$(DoNotCopyLocalIfInGac)"
    ResolvedSDKReferences="@(ResolvedSDKReference)"
    WarnOrErrorOnTargetArchitectureMismatch="$(ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch)"
    IgnoreTargetFrameworkAttributeVersionMismatch ="$(ResolveAssemblyReferenceIgnoreTargetFrameworkAttributeVersionMismatch)"
    FindDependenciesOfExternallyResolvedReferences="$(FindDependenciesOfExternallyResolvedReferences)"
    ContinueOnError="$(ContinueOnError)"
    Condition="‘@(Reference)‘!=‘‘ or ‘@(_ResolvedProjectReferencePaths)‘!=‘‘ or ‘@(_ExplicitReference)‘ != ‘‘"
    >

    <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
    <Output TaskParameter="ResolvedFiles" ItemName="_ResolveAssemblyReferenceResolvedFiles"/>
    <Output TaskParameter="ResolvedDependencyFiles" ItemName="ReferenceDependencyPaths"/>
    <Output TaskParameter="RelatedFiles" ItemName="_ReferenceRelatedPaths"/>
    <Output TaskParameter="SatelliteFiles" ItemName="ReferenceSatellitePaths"/>
    <Output TaskParameter="SerializationAssemblyFiles" ItemName="_ReferenceSerializationAssemblyPaths"/>
    <Output TaskParameter="ScatterFiles" ItemName="_ReferenceScatterPaths"/>
    <Output TaskParameter="CopyLocalFiles" ItemName="ReferenceCopyLocalPaths"/>
    <Output TaskParameter="SuggestedRedirects" ItemName="SuggestedBindingRedirects"/>
    <Output TaskParameter="FilesWritten" ItemName="FileWrites"/>
    <Output TaskParameter="DependsOnSystemRuntime" PropertyName="DependsOnSystemRuntime"/>
    <Output TaskParameter="DependsOnNETStandard" PropertyName="_DependsOnNETStandard"/>
</ResolveAssemblyReference>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

从这个 Task 中可以看出,它还输出了以下这些属性或集合:

  • ReferenceDependencyPaths
  • ReferenceSatellitePaths
  • ReferenceCopyLocalPaths
    • 这是需要拷贝到本地的那些 dll 的路径(不含框架自带的 dll)
  • SuggestedBindingRedirects
  • FileWrites
    • 要写入的一些缓存文件
  • DependsOnSystemRuntime
    • 以上都是集合,唯独这是一个布尔值,表示是否依赖系统运行时

我的博客会首发于 https://walterlv.com/,而 CSDN 和博客园仅从其中摘选发布,而且一旦发布了就不再更新。

如果在博客看到有任何不懂的内容,欢迎交流。我搭建了 dotnet 职业技术学院 欢迎大家加入。

技术图片

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名吕毅(包含链接:https://blog.csdn.net/wpwalter),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系

发布了382 篇原创文章 · 获赞 232 · 访问量 47万+

以上是关于在 Target 中获取项目引用的所有依赖(dll/NuGet/Project)的路径的主要内容,如果未能解决你的问题,请参考以下文章

在 Visual Studio 2013 中添加对您自己的 DLL 项目的依赖项/引用

在 Visual Studio 中复制 DLL 的依赖项

同一个解决方案或有依赖关系的两个项目引用同名但不同版本的DLL

无法将本机 .dll 引用添加到源生成器项目

通过 dll 引用而不是 VS 中的项目引用来管理 .NET 程序集依赖项

未复制到输出目录的引用的依赖关系