k0s*_*t1x 8 .net c# msbuild csproj .net-core
我有一个带有经典参考的.NetCore平台的.csproj。我正在为开发环境使用该属性。但是我应该在 CI 环境中构建csproj,其中引用的程序集放置在不同的目录中。在经典的net4 上,我使用了MSBuild工具的参数。但是“dotnet build”没有类似的论点。作为后备,我找到了“dotnet msbuild”命令,但此工具忽略了该参数并向我显示hintpath/p:ReferencePath/p:ReferencePath=xxx
警告 MSB3245:无法解析此引用。找不到程序集“AssemblyName”。检查以确保程序集存在于磁盘上。如果您的代码需要此引用,您可能会收到编译错误。
请指导我,我可以检查什么,dotnet-build / dotnet-msbuild工具在哪里搜索引用的程序集以及如何指定该目录?
小智 5
问题是由 Microsoft.NET.Sdk.props 提出的:AssemblySearchPaths 没有 ReferencePath。通过添加到 csproj 修复:
<PropertyGroup>
<AssemblySearchPaths>
$(AssemblySearchPaths);
$(ReferencePath);
</AssemblySearchPaths>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
referencePath被新项目文件格式忽略。/t:restore到 msbuild 命令,因此它将同时恢复和构建。 <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>
Run Code Online (Sandbox Code Playgroud)
这将允许您只需更改 CI/Build 中的配置名称即可完成这项工作。
| 归档时间: |
|
| 查看次数: |
2380 次 |
| 最近记录: |