久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 TeamCity 的“dotnet restore"與“nuget restore

#39;dotnet restore#39; vs. #39;nuget restore#39; with TeamCity(使用 TeamCity 的“dotnet restore與“nuget restore)
本文介紹了使用 TeamCity 的“dotnet restore"與“nuget restore"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個可以使用 Visual Studio 正確構建的 ASP.NET Core 項目,但它不能在 MSBuild 下構建.

I have an ASP.NET Core project that builds properly with Visual Studio, but it doesn't build under MSBuild.

它沒有找到所有的通用庫(系統等).

It doesn't find all the common libraries (system, etc.).

我正在使用 TeamCity,構建過程的一部分是 nuget restore.

I'm using TeamCity and part of the build process is a nuget restore.

我嘗試執行與 TeamCity 相同的步驟,但使用 MSBuild 手動執行,但失敗了,找不到庫.

I tried to do the same steps as TeamCity, but manually with MSBuild, and it failed, not finding the libraries.

我添加了一個 dotnet restore 步驟,然后它起作用了.

I added a dotnet restore step and then it worked.

那么,nuget restoredotnet restore 有什么區別?

So, what is the difference between a nuget restore and a dotnet restore?

推薦答案

nuget restoredotnet restore 大致相同:它們執行 NuGet 恢復操作.

Both nuget restore and dotnet restore are roughly the same: They perform a NuGet restore operation.

唯一的區別:dotnet restore 是調用 dotnet msbuild/t:Restore 的便捷包裝器,它調用 MSBuild 集成的恢復.這僅適用于包含 NuGet 的 MSBuild 發行版,例如 Visual Studio 2017(完整的 Visual Studio,構建工具)或 Mono 5.2+ (=> msbuild/t:Restore) 和 .NET Core提供此便捷命令的 SDK.

The only difference: dotnet restore is a convenience wrapper to invoke dotnet msbuild /t:Restore which invokes an MSBuild-integrated restore. This only works on MSBuild distributions that include NuGet, such as Visual Studio 2017 (full Visual Studio, build tools) or Mono 5.2+ (=> msbuild /t:Restore) and the .NET Core SDK which provides this convenience command.

目前,有兩種方法可以在項目中使用 NuGet 包(實際上是三種,但我們暫時忽略 UWP 上的 project.json):

At the moment, there are two ways of how NuGet packages can be used in projects (three actually, but let's ignore project.json on UWP for the moment):

  • packages.config:引用 NuGet 包的經典"方式.這假定 NuGet 是一個單獨的工具,并且 MSBuild 對 NuGet 一無所知.NuGet 客戶端(例如 nuget.exe 或 Visual Studio 集成工具)會看到 packages.config 文件并在還原時將引用的包下載到本地文件夾中.包安裝會修改項目以引用此本地文件夾之外的資產.因此,packages.config 項目的恢復只會下載文件.
  • PackageReference:項目包含引用 NuGet 包的 MSBuild 項.與 packages.config 不同,僅列出了直接依賴項,并且項目文件不直接引用包中的任何資產(DLL 文件、內容文件).在還原時,NuGet 通過評估直接和傳遞依賴關系來計算依賴關系圖,確保所有包都下載到用戶的全局包緩存中(不是本地解決方案,因此只下載一次)并將資產文件寫入 obj 文件夾,其中包含項目使用的所有包和資產的列表,以及其他 MSBuild 目標(如果任何包包含需要添加到項目的構建邏輯).因此,如果包尚未在全局緩存中,NuGet 還原可能會下載包并創建此資產文件.除了包引用,項目還可以引用 CLI 工具,這些工具是 NuGet 包,其中包含可用于項目目錄中的 dotnet 的附加命令.
  • packages.config: The "classic" way of referencing NuGet packages. This assumes NuGet is a separate tool and MSBuild doesn't know anything about NuGet. A NuGet client such as nuget.exe or Visual Studio-integrated tooling sees the packages.config file and downloads the referenced packages into a local folder on restore. A package install modifies the project to reference assets out of this local folder. So a restore for a packages.config project only downloads the files.
  • PackageReference: The project contains MSBuild items that reference a NuGet package. Unlike packages.config, only the direct dependencies are listed and the project file does not directly reference any assets (DLL files, content files) out of packages. On restore, NuGet figures out the dependency graph by evaluating the direct and transitive dependencies, makes sure all packages are downloaded into the user's global package cache (not solution-local so it is only downloaded once) and write an assets file into the obj folder that contains a list of all packages and assets that the project uses, as well as additional MSBuild targets if any package contains build logic that needs to be added to a project. So a NuGet restore may download packages if they are not already in the global cache and create this assets file. In addition to package references, the project can also reference CLI tools, which are NuGet packages containing additional commands that will be available for the dotnet in the project directory.

msbuild-integrated restore 僅適用于 PackageReference 類型的項目(默認為 .NET Standard、.NET Core,但它適用于任何 .NET 項目),不適用于 packages.config 項目.如果您使用新版本的 nuget.exe(例如 4.3.0),它可以恢復兩種項目類型.

The msbuild-integrated restore only works for PackageReference type projects (.NET Standard, .NET Core by default, but it is opt-in for any .NET project) and not for packages.config projects. If you use a new version of nuget.exe(e.g. 4.3.0), it is able to restore both project types.

您關于缺少類型的錯誤更有趣:參考程序集"(作為輸入傳遞給編譯器的庫)未安裝在系統上,而是通過 NuGet 包安裝.因此,只要全局包緩存中缺少 NuGet 包,或者還原操作未生成 obj/project.assets.json 文件,System.Object<等基本類型/code>編譯器將無法使用.

Your error about missing types is a bit more interesting: The "reference assemblies" (libraries that are passed as input to the compiler) are not installed on the system but come via NuGet packages. So as long as the NuGet packages are missing from the global package cache or the obj/project.assets.json file has not been generated by a restore operation, fundamental types like System.Objectwill not be available to the compiler.

這篇關于使用 TeamCity 的“dotnet restore"與“nuget restore"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網站添加了書簽?)
Use of Different .Net Languages?(使用不同的 .Net 語言?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點的“活動用戶數)
Best way to keep track of current online users(跟蹤當前在線用戶的最佳方式)
Recommend an Open Source .NET Statistics Library(推薦一個開源的.NET統計庫)
Create a summary description of a schedule given a list of shifts(給定輪班列表,創建時間表的摘要描述)
主站蜘蛛池模板: 二区国产 | 国户精品久久久久久久久久久不卡 | 日韩欧美国产一区二区 | 欧美久久精品一级c片 | 亚洲日韩中文字幕 | 国产福利在线视频 | 日韩精品在线观看免费 | 91精品国产99 | 黄色毛片在线看 | 午夜天堂精品久久久久 | 九九九视频| 一区二区三区视频 | 国产免费一区二区三区免费视频 | 国产精品久久久久久一区二区三区 | 日韩视频在线一区二区 | 亚洲一区二区三区在线视频 | 荷兰欧美一级毛片 | 久久国产精品久久久久久 | 亚洲欧美网站 | 亚洲一区中文字幕 | 在线中文一区 | 中文字幕综合 | 国产伦精品一区二区三区照片91 | 国产综合视频 | 亚洲国产成人精 | a级免费视频 | 超碰网址 | 自拍偷拍亚洲一区 | 精品少妇v888av | 伊人伊成久久人综合网站 | 成人综合一区二区 | 亚洲在线一区二区 | 视频二区 | 视频一区二区中文字幕 | 日韩中文不卡 | 欧美日韩国产精品一区二区 | 国产高清视频在线 | 黄色成人免费看 | 午夜电影网站 | 在线观看视频91 | 91免费高清视频 |