c# – .NET Core – 构建指定ReferencePath的项目

我有一个带有经典引用的.NetCore平台的.csproj.我正在使用开发环境的hintpath属性.但是我应该在CI环境中构建csproj,其中引用的程序集放在不同的目录中.
在经典的net4上,我使用了MSBuild工具的/ p:ReferencePath参数.
但“dotnet构建”没有类似的论点.
作为后备,我找到了“dotnet msbuild”命令,但是这个工具忽略了/ p:ReferencePath = xxx参数并显示了我

warning MSB3245: Could not resolve this reference. Could not locate the assembly “AssemblyName”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

请指导我,我可以检查,dotnet-build / dotnet-msbuild工具在哪里搜索引用的程序集以及如何指定该目录?

解决方法:

>您仍然可以使用MSBUILD在解决方案中构建.net CORE / Standard项目.
>这似乎是我向Microsoft报告的一个错误(这不是关于核心/标准而是新的项目文件格式),新的项目文件格式会忽略referencePath.
>提供add / t:恢复到msbuild命令以及构建目标,因此它将同时恢复和构建.
> CI / Build服务器情况的解决方法是创建一个特殊的解决方案配置,并在项目文件中添加类似以下的内容

<Choose>  
  <When Condition="'$(Configuration)|$(Platform)'=='YourSpecialConfiguration|x64'"><!-- attention here -->
    <ItemGroup>
      <Reference Include="your.dllname">
        <HintPath>yourSpecialPath\your.dllname.dll</HintPath><!-- attention here -->
        <Private>true</Private>
      </Reference>
      <!-- more references here -->
  </When>
  <Otherwise>
    <ItemGroup>
      <Reference Include="your.dllname">
        <HintPath>yourRegularPath\your.dllname.dll</HintPath><!-- attention here -->
        <Private>true</Private>
      </Reference>
      <!-- AND more references here -->
  </Otherwise>
</Choose>  

这将允许您只更改CI / Build中的配置名称并执行此任务.

上一篇:UIPickerView实现省 市 区三级联动


下一篇:c# – Msbuild v15无法解析nuspec文件的元数据变量