在csproj文件中使用AssemblySearchPaths [英] using AssemblySearchPaths in csproj files

查看:82
本文介绍了在csproj文件中使用AssemblySearchPaths的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过添加以下内容来设置我的csproj文件以搜索父目录中的依赖项:

I am trying to set up my csproj files to search for dependencies in a parent directory by adding:

<PropertyGroup>
    <AssemblySearchPaths>
       ..\Dependencies\VS2012TestAssemblies\; $(AssemblySearchPaths)
   </AssemblySearchPaths>
</PropertyGroup>

我将其添加为最后一个PropertyGroup元素,紧接在具有所有Reference声明的第一个ItemGroup之前。

I added this as the last PropertyGroup element right before the first ItemGroup which has all of the Reference declarations.

不幸的是,这导致所有其他引用都无法解析,例如:

Unfortunately this is causing all of the other references to fail to resolve, for example:

ResolveAssemblyReferences:
         Primary reference "Microsoft.CSharp".
     9>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 
For SearchPath "..\Dependencies\VS2012TestAssemblies\".
                 Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.winmd", but it didn't exist.
                 Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.dll", but it didn't exist.
                 Considered "..\Dependencies\VS2012TestAssemblies\Microsoft.CSharp.exe", but it didn't exist.

我是否可以通过一种简单的方法告诉msbuild在哪里搜索项目的依赖项?我意识到我可以使用/ p:ReferencePath,但是我更喜欢在csproj文件本身中包含编译逻辑,而不是让TFS Team Build指示要查找的位置,更不用说我希望能够在其他位置上进行编译开发人员机器。

Is there a simple way for me to tell msbuild to where to search for my project's dependencies? I realize I can use /p:ReferencePath, however I prefer to have compilation logic in the csproj files themselves rather than have TFS Team Builds dictate where to look, not to mention that I'd like this to be able to be compiled on other developers machines.

我确实尝试将$(AssemblySearchPaths)移到列表的第一位,但这并没有帮助。

I did try moving $(AssemblySearchPaths) to be first in list, but that did not help.

推荐答案

可以在目标 BeforeResolveReferences内更改 AssemblySearchPaths属性的值,看看是否可以解决您的问题?

Can you change the value of the "AssemblySearchPaths" property within the Target "BeforeResolveReferences" and see if that solves your issue?

    <Target Name="BeforeResolveReferences">
<CreateProperty
    Value="..\Dependencies\VS2012TestAssemblies;$(AssemblySearchPaths)">
    <Output TaskParameter="Value"
        PropertyName="AssemblySearchPaths" />
</CreateProperty>
</Target>

这篇关于在csproj文件中使用AssemblySearchPaths的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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