Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using AssemblySearchPaths in csproj files

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>

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.

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.

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

like image 588
JohnZaj Avatar asked Oct 11 '13 03:10

JohnZaj


1 Answers

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>
like image 146
Isaiah4110 Avatar answered Nov 01 '22 00:11

Isaiah4110