Using AssemblySearchPaths in csproj files

I am trying to configure my csproj files to look for dependencies in the parent directory by adding:

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

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

Unfortunately, this leads to the fact that all other links cannot be resolved, 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 an easy way to tell msbuild where to look for my project dependencies? I understand that I can use / p: ReferencePath, but I prefer to have compilation logic in the csproj files themselves, rather than that TFS Team Builds dictates where to look, not to mention that I would like it to be compiled on another by machine developers.

I tried moving $ (AssemblySearchPaths) first on the list, but that didn't help.

+6
source share
1 answer

Can you change the value of the AssemblySearchPaths property in the target "BeforeResolveReferences" and see if this solves the problem for you?

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

Source: https://habr.com/ru/post/955733/


All Articles