MSBuild ReferenceDependencyPaths不包含第n个依赖项 [英] MSBuild ReferenceDependencyPaths does not contain nth dependencies

查看:138
本文介绍了MSBuild ReferenceDependencyPaths不包含第n个依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用msbuild进行构建时,我试图获取所有依赖项的列表.我正在尝试使用ReferenceDependencyPaths,我很确定它应该包含二阶和n阶依赖项.当我使用它时,我得到了一些二阶依赖关系,但不是全部,而且我缺少了所有的三阶依赖关系或更高的依赖关系.我尝试执行此操作的原因是可以将依赖项的依赖项复制到要构建的项目的bin文件夹中.

I am attempting to get a list of all my dependencies when I go to build with msbuild. I am trying to use the ReferenceDependencyPaths which I am pretty sure should contain second and nth-order dependencies. When I use this I am getting some of the second order dependencies but not all of them and I am missing all of my 3rd order or higher dependencies. The reason I am attempting to do this is so I can copy my dependencies', dependencies to the bin folder of the project I am building.

我的解决方案基于此博客文章 http ://blog.alexyakunin.com/2009/09/making-msbuild-visual-studio-to.html ,因为他的解决方案对我来说不是开箱即用的.

I based my solution off of this blog post http://blog.alexyakunin.com/2009/09/making-msbuild-visual-studio-to.html because his solution wasn't working for me out of the box.

到目前为止,这是我的解决方案,不幸的是,该解决方案复制了一些框架dll,但缺少了诸如ninject之类的其他dll.

This is my solution so far which unfortunately copies some framework dlls but is missing other dlls like ninject.

有人知道我是否应该使用其他项目或属性来获取依赖项吗?在这种情况下,ninject也来自nuget,是在其他地方解析nuget引用,并将它们存储在什么属性或项目中?

Does anyone know if their is a different item or property I should be using to get my dependencies', dependencies? Also ninject in this case is coming from nuget, are nuget references resolved some where else and what property or item would they be stored in?

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
    <CopyIndirectDependenciesCondition="'$(CopyIndirectDependencies)'==''">true</CopyIndirectDependencies>
</PropertyGroup>

<!-- BuildXxx part -->
<Target Condition="'$(CopyIndirectDependencies)'=='true'"DependsOnTargets="DetectIndirectDependencies" Name="CopyIndirectDependencies">
    <Message Importance="low" Text="Direct dependency: %(ReferencePath.Filename)%(ReferencePath.Extension)" />
    <Message Importance="low" Text="Indirect dependency: %(ReferenceDependencyPaths.Filename)%(ReferenceDependencyPaths.Extension) Full Path: @(IndirectDependency)"/>

    <Copy Condition="'%(ReferenceDependencyPaths.RootDir)%(ReferenceDependencyPaths.Directory)%(ReferenceDependencyPaths.Filename)%(ReferenceDependencyPaths.Extension)'!=''" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="false" SourceFiles="@(IndirectDependency)">
      <Output ItemName="IndirectDependencyCopied" TaskParameter="CopiedFiles"/>
    </Copy>
</Target>

<Target DependsOnTargets="ResolveAssemblyReferences" Name="DetectIndirectDependencies">
<!-- Creating indirect dependency list -->
   <CreateItem Condition="'%(ReferenceDependencyPaths.RootDir)%(ReferenceDependencyPaths.Directory)%(ReferenceDependencyPaths.Filename)%(ReferenceDependencyPaths.Extension)'!=''" Include="%(ReferenceDependencyPaths.RootDir)%(ReferenceDependencyPaths.Directory)%(ReferenceDependencyPaths.Filename)%(ReferenceDependencyPaths.Extension)">
     <Output ItemName="IndirectDependency" TaskParameter="Include"/>
   </CreateItem>
</Target>

<!-- Build sequence modification -->
<PropertyGroup>
  <CoreBuildDependsOn>$(CoreBuildDependsOn);CopyIndirectDependencies
  </CoreBuildDependsOn>
</PropertyGroup>
</Project>

推荐答案

我在此处留下了评论,

当间接依赖来自NuGet时,它对我不起作用 软件包(Microsoft.AspNet.WebApi.Client和Newtonsoft.Json).但是 提示中所述 http://www.paraesthesia.com/archive/2014/05/09/recursively-copying-indirect-project-dependencies-in-msbuild.aspx/ 解决了这个问题.我认为它使用更合适的间接依赖 检测方法.

It does not work for me when the indirect dependency comes from NuGet packages (Microsoft.AspNet.WebApi.Client and Newtonsoft.Json). But the tip described in http://www.paraesthesia.com/archive/2014/05/09/recursively-copying-indirect-project-dependencies-in-msbuild.aspx/ solves the issue. I think it uses a more suitable indirect dependency detection approach.

这篇关于MSBuild ReferenceDependencyPaths不包含第n个依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆