1. 程式人生 > 實用技巧 >如何為VS2017製作離線安裝程式

如何為VS2017製作離線安裝程式

I just got back from Kenya and South Africa and had a great time speaking at NexTech Africa and the Microsoft Tech Summit in Johannesburg. I also got to hang out with my wife's family a bunch. While I was there I was reminded (as one is when one travels) how spoiled many of us with being always connected. Depending on how far out of town you get the quality of internet varies. There's not just bandwidth issues but also issues of latency and reliability.

我剛從肯亞和南非回來,在NexTech Africa和約翰內斯堡的Microsoft Tech Summit上度過了愉快的時光。 我還得和我妻子的家人一起出去玩。 當我在那兒時,我被提醒(就像一個人旅行一樣)如何使我們許多人始終保持聯絡而寵壞了。 根據您到達城鎮的距離,網際網路的質量會有所不同。 不僅存在頻寬問題,而且還存在延遲和可靠性問題。

Visual Studio generally - and Visual Studio 2017 specifically - has an online installer and if you lose connectivity during the installation you can run into problems. However, they haven't got an ISO available for downloading for legal reasons. They can't package up the Android Installer from Google, for example, into an ISO. The user needs to download certain things themselves dynamically.

通常,Visual Studio(尤其是Visual Studio 2017)具有線上安裝程式,如果在安裝過程中失去連線,可能會遇到問題。 但是,由於法律原因,他們沒有可供下載的ISO。 他們無法將Google提供的Android Installer打包成一個ISO。 使用者需要自己動態下載某些內容。

Fortunately there's docs that walk you through making an offline installer. These could be used to create USB sticks or DVDs that could then be passed out at User Groups or free Events.

幸運的是,有一些文件可以指導您完成離線安裝程式。 這些可以用來建立USB記憶棒或DVD,然後可以在使用者組或免費活動中傳遞出去。

  • First, I went to http://visualstudio.com/free and clicked Download. I use VS Community but you can also do this for Enterprise, etc. I downloaded the bootstrapper .exe and put it in its own folder.

    首先,我轉到http://visualstudio.com/free,然後單擊“下載”。 我使用VS Community,但您也可以針對Enterprise等使用。我下載了bootstrapper .exe並將其放在自己的資料夾中。

  • If you want EVERYTHING possible then you'd run something like this. Note that is my folder there and I selected en-US as my language.

    如果您希望一切皆有可能,那麼您將執行類似的內容。 請注意,這是我的資料夾,我選擇了en-US作為我的語言。

    If you want EVERYTHING possible then you'd run something like this. Note that is my folder there and I selected en-US as my language.vs_community.exe --layout e:\vs2017offline --lang en-US

    如果您希望一切皆有可能,那麼您將執行類似的內容。 請注意,這是我的資料夾,我選擇了en-US作為我的語言。 vs_community.exe --layout e:\ vs2017offline --lang zh-CN

  • However if you don't want EVERYTHING - maybe you just want .NET Core, ASP.NET Core, and Azure, then you'll pass those options in on the command line. They call them "Workloads" but that's a Microsoftism.

    但是,如果您不想要任何東西-也許您只想要.NET Core,ASP.NET Core和Azure,那麼您將在命令列中傳遞這些選項。 他們稱它們為“工作量”,但這是一種微軟主義。

    • Here is a list of all the Component IDs you can choose from.

      這是您可以選擇的所有元件ID的列表。

    • I did this to get an offline setup for my main four "workloads." I ran this from a cmd prompt.

      我這樣做是為了為我的主要四個“工作量”提供離線設定。 我是從cmd提示符執行的。

      I did this to get an offline setup for my main four "workloads." I ran this from a cmd prompt.vs_community.exe --layout e:\vs2017offline --lang en-US --add Microsoft.VisualStudio.Workload.Azure Microsoft.VisualStudio.Workload.ManagedDesktop Microsoft.VisualStudio.Workload.NetCoreTools Microsoft.VisualStudio.Workload.NetWeb

      我這樣做是為了為我的主要四個“工作量”提供離線設定。 我是從cmd提示符執行的。 vs_community.exe --layout e:\ vs2017offline --lang-zh-CN --add Microsoft.VisualStudio.Workload.Azure Microsoft.VisualStudio.Workload.ManagedDesktop Microsoft.VisualStudio.Workload.NetCoreTools Microsoft.VisualStudio.Workload.NetWeb

It will go and download everything you need. If you want everything then it'll take a while, so hang back.

它會去下載您需要的一切。 如果您需要所有內容,則需要一些時間,因此請稍候。

Give us a minute, we'll be done soon...

If you have trouble or nothing happens, check the dd_bootstrapper*.log file in %TEMP%.

如果遇到問題或什麼都沒有發生,請檢查%TEMP%中的dd_bootstrapper * .log檔案。

DOS prompt downloading Visual Studio

When it's all done you'll end up with a folder like this that you can copy to a DVD or USB key.

完成後,您將得到一個像這樣的資料夾,您可以將其複製到DVD或USB快閃記憶體盤。

The result of the VS offline Layout generator

One nice aspect of this system is that you can update a "layout" in place. As updates become available for Visual Studio 2017 (RC or otherwise), you can run the --layout command again, pointing to the same layout folder, to ensure that the folder contains the latest components. Only those components that have been updated since the last time --layout was run will be downloaded.

該系統的一個不錯的方面是您可以就地更新“佈局” 。 隨著更新可用於Visual Studio 2017(RC或其他),您可以再次執行--layout命令,指向同一佈局資料夾,以確保該資料夾包含最新元件。 僅下載自上次執行--layout以來已更新的那些元件。

IMPORTANT NOTE: Make sure that your file is named "vs_[SKU].exe." Sometimes you'll end up with a file like vs_community__198521760.1486960229.exe and you'll want to rename it to vs_community.exe for offline to work.

重要說明:確保您的檔名為“ vs_ [SKU] .exe”。 有時,您最終會得到一個類似vs_community__198521760.1486960229.exe的檔案,並且您希望將其重新命名為vs_community.exe以便離線工作。

Before you run the installer, you'll want to install the root certificates in the \certificates folder. From the team:

在執行安裝程式之前,您需要在\ certificates資料夾中安裝根證書。 來自團隊:

They are the root certs needed to verify the setup application (the stuff installed under ProgramFiles\Visual Studio\2017\Installer) and the catalog (a json file that lists of all the VS components that could be installed by setup). Most computers will already have these root certs. But users on Win7 machine may not. Once you install these certs, setup will be able to authenticate the content being installed is trusted. You should not remove them after installing them.

它們是驗證安裝程式(安裝在ProgramFiles \ Visual Studio \ 2017 \ Installer下的東西)和目錄(列出安裝程式可以安裝的所有VS元件的json檔案)所需的根證書。 大多數計算機將已經具有這些根證書。 但是Win7計算機上的使用者可能不會。 安裝這些證書後,安裝程式將能夠驗證所安裝內容的可信性。 安裝它們後,請勿刪除它們。

I hope this helps you set up offline installers for your classrooms and organizations! You'll save a lot of bandwidth.

我希望這可以幫助您為教室和組織機構設定離線安裝程式! 您將節省大量頻寬。



Sponsor: Big thanks to Raygun! Join 40,000+ developers who monitor their apps with Raygun. Understand the root cause of errors, crashes and performance issues in your software applications. Installs in minutes, try it today!

贊助商:非常感謝Raygun ! 加入40,000多名使用Raygun監視其應用程式的開發人員。 瞭解軟體應用程式中錯誤,崩潰和效能問題的根本原因。 數分鐘即可安裝,立即嘗試

關於斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·漢塞爾曼(Scott Hanselman)是前教授,前金融首席架構師,現在是演講者,顧問,父親,糖尿病患者和Microsoft員工。 他是一位失敗的單口相聲漫畫家,一個玉米種植者和一本書的作者。

facebook twitter subscribe About 關於 Newsletter 時事通訊 Hosting By 主持人 Hosted in an Azure App Service

翻譯自: https://www.hanselman.com/blog/how-to-make-an-offline-installer-for-vs2017