Get NuGet package folder in MSBuild

前端 未结 1 698
余生分开走
余生分开走 2021-02-19 10:23

I want to call executable tools like NUnit which I manage via NuGet in MSBuild:


  

        
相关标签:
1条回答
  • 2021-02-19 10:45

    You can use MSBuild Transforms to get the relative directory of a specific tool:

    <ItemGroup>
      <NunitPackage Include="$(PackagesDirectory)\NUnit.*\tools\nunit-console.exe"/>
    </ItemGroup>
    
    <Target Name="Test">
      <CreateItem Include="$(BuildCompileDirectory)\*.Tests.*dll">
        <Output TaskParameter="Include" ItemName="TestAssemblies" />
      </CreateItem>
      <NUnit
        Assemblies="@(TestAssemblies)"
        ToolPath="@(NunitPackage->'%(relativedir)')"
        WorkingDirectory="$(BuildCompileDirectory)"
        OutputXmlFile="$(BuildDirectory)\$(SolutionName).Tests.xml" />
    </Target>
    
    0 讨论(0)
提交回复
热议问题