using AssemblySearchPaths in csproj files

后端 未结 2 838
清歌不尽
清歌不尽 2021-02-08 10:28

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


    
       ..         


        
相关标签:
2条回答
  • 2021-02-08 11:07

    Seems like there was a fix recently Thus this works as well:

    <PropertyGroup>
      <ReferencePath>MY_PATH;$(ReferencePath)</ReferencePath>
    </PropertyGroup>
    

    This makes the assemblies in that folder to also show up in the "Add References..." window :)


    And since you also might not want the assemblies to be copied into the output-folder, here an example on how to achieve this:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <!-- ... -->
    
      <PropertyGroup>
        <!-- Add paths to ReferencePath. E.g. here it is Unity. -->
        <ReferencePath>C:\Program Files\Unity\Hub\Editor\$(UNITY_VERSION)\Editor\Data\Managed\UnityEngine;$(ReferencePath)</ReferencePath>
      </PropertyGroup>
    
      <Target Name="DontCopyReferencePath" AfterTargets="ResolveAssemblyReferences">
        <!-- Don't copy files indirectly referenced by ReferencePath -->
        <ItemGroup>
          <!-- Collect paths to allow for batching -->
          <ReferencePaths_ Include="$(ReferencePath)" />
          <!-- Use batching to remove all files which should not be copied. -->
          <ReferenceCopyLocalPaths Remove="@(ReferencePaths_ -> '%(Identity)\*.*')" />
        </ItemGroup>
      </Target>
    
      <!-- ... -->
    </Project>
    
    0 讨论(0)
  • 2021-02-08 11:19

    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>
    
    0 讨论(0)
提交回复
热议问题