c# - Travis 上的 dotnet 恢复
问题描述
我在一个解决方案中有一个基于微服务的应用程序,但它有几个项目 - 正好 5 个。我有一些想在 Travis CI 上构建的 xUnit 测试,但是我遇到了The command "dotnet restore" failed and exited with 1 during
错误。这是我第一次与 Travis 合作。
我的 travis.yml 文件
language: csharp
mono: none
dotnet: 3.1.202
sudo: required
before_install:
- sudo apt-get install nuget
install:
- dotnet restore
branches:
only:
- Testing
script:
- dotnet build
- dotnet test TestCore/TestCore.csproj"
Travis 的输出:
Installing .NET Core
0.00s
git.checkout
0.71s$ git clone --depth=50 --branch=Testing https://github.com/NagyDominik/OnlineRetailer_Partial.git NagyDominik/OnlineRetailer_Partial
0.01s
0.11s$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.202
Commit: 6ea70c8dca
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/3.1.202/
Host (useful for support):
Version: 3.1.4
Commit: 0090613580
.NET Core SDKs installed:
3.1.202 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
before_install
17.04s$ sudo apt-get install nuget
$ dotnet restore
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.202
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
More than one project or solution file.
The command "dotnet restore" failed and exited with 1 during .
Your build has been stopped.
任何建议都非常受欢迎!
解决方案
您的 github 项目在主目录中有多个项目/解决方案文件:
OnlineRetailer.sln
docker-compose.dcproj
如果您在项目的主目录中有多个项目或解决方案文件,dotnet build
可能会感到困惑并且不知道要构建什么。
你只需要告诉dotnet build
你想要构建什么。例如:
- dotnet build OnlineRetailer.sln
顺便说一句,我认为你根本不需要这个:
sudo apt-get install nuget
SDK 是独立的,包含它需要做的 nuget 部分dotnet restore
。
推荐阅读
- postgresql - 同一查询 postgresql/jpa 中的不同结果
- java - 如何动态设置类的通用参数?
- python - 从数据框行创建数组
- javascript - 单击内部链接/按钮时取消/防止 Bootstrap5 崩溃
- python - 关于 PyFlink 使用 execute_sql 选择表并使用 table.print() 的问题
- azure - Azure DevOps Release Pipelines 已停止无法下载工件
- docker - 我在 Nexus 3 中找不到 jetty-https.xml
- reactjs - 我收到一个奇怪的警告“React hook useEffect 缺少依赖项”
- sap-cloud-sdk - 如何在 Sap Cloud Sdk 中为 javacript 项目调用 Soap Web 服务
- python - 使用 python3 并连接到 sqlite3 我想显示我的数据库中的表,“。” 在“.tables”中不断给出错误,“\”没有帮助