xamarin.forms - NuGet 如何决定将包目录放在哪里?
问题描述
我正在处理一些 Xamarin Forms 项目和生成多目标 Xamarin 包的项目。我花了一天时间努力让其中一个项目在 Azure DevOps 中正常工作,但我放弃了。
当我在本地处理一个特定的单元测试项目时,它会设置这个目录结构:
+ ProjectName
+ bin
+ obj
+ ...
+ packages
+ <nuget packages here>
这种结构体现在项目文件的部分内容中,如下所示:
<Import Project="..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" />
项目文件的另一部分取决于此:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props'))" />
</Target>
当我在本地构建它时,一切都很好。项目构建。测试通过。当我在 Azure DevOps 中构建它时,它失败了:
(EnsureNuGetPackageBuildImports target) ->
D:\a\1\s\[Redacted].Unit.Tests\[Redacted].Unit.Tests.csproj(97,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\..\packages\NUnit.3.12.0\build\NUnit.props.
packages
很明显,Azure DevOps 对文件夹的创建位置有不同的想法。如果我编辑..\..
to ..\
,一切正常。这与很多项目一致。在我的其他几个项目中,所有 .csproj 文件都使用..\
并且它们具有以下目录结构:
+ ProjectName
+ bin
+ obj
+ packages
+ ...
我在任何一个中都找不到任何.csproj
似乎表明任何一个都在指示 nuget 以不同方式做任何事情的东西。但是每个人的行为都非常不同。我唯一的猜测是我有一些超级隐藏的本地配置用于“损坏”的更改默认行为的配置,并且该文件不在源代码控制中,因此 DevOps 使用“真实”默认值?
什么可能导致这种情况发生?
有些人要求 .yml 以查看我们如何恢复包:我相信就是这样:
- task: NuGetToolInstaller@1
displayName: "Install nuget"
inputs:
versionSpec: '4.4.1'
- task: NuGetCommand@2
displayName: 'restore $(solution)'
inputs:
restoreSolution: '$(solution)'
vstsFeed: "$(packageFeedName)"
我不是团队的devops 人,但我对 yml了解一些。$(solution)
只是我们解决方案文件的路径,包提要名称就是它所说的。他们对我来说似乎很简单。
解决方案
推荐阅读
- kubernetes - 在 Kubernetes 与 AWS ECS 之间进行选择
- javascript - 在选择中获取键的名称
- angular - 将打字稿库添加到角度
- spring-boot - Spring Boot Security 错误:编码密码看起来不像 BCrypt,从内存认证转换为数据库认证
- python - 词袋标记每个字母而不是单词
- python - 尝试在 python 中为文本文件中的数量级制作直方图
- javascript - 如何在 vue.js 上接收 HTTP POST 参数?
- prestashop-1.7 - 在产品页面点击保存按钮后挂钩
- javascript - 将两个数组变成json数据
- dialogflow-es - 从我的 Actions on Google 链接到 Web url