Giter VIP home page Giter VIP logo

installnetcoreruntimeandhostingtask's Introduction

Archived

This repository has been archived. No new features are added, because .NET Core is included in Microsoft Update now. For more information see .NET Core coming to Microsoft Update.

Install .NET Core Runtime & Hosting Task

Azure DevOps pipeline task that downloads and installs the latest .NET Core runtime and hosting bundle.

.NET Core coming to Microsoft Update

Starting in December 2020 .NET Core has been added to Microsoft Update. Before you proceed and use this custom extension, have a look at .NET Core coming to Microsoft Update.

Supported .NET Core versions

  • 2.1
  • 2.2
  • 3.0
  • 3.1
  • 5.0
  • 6.0

YAML snippet

# Install the .NET Core runtime and hosting bundle
- task: InstallNetCoreRuntimeAndHosting@1
  inputs:
    #version: '3.0' # Options: 2.1, 2.2, 3.0, 3.1, 5.0, 6.0
    #useProxy: false
    #proxyServerAddress: # Required when useProxy == true
    #norestart: false
    #iisReset: true
    #installArguments: # Optional

Arguments

Name Description
version
Version
Version of .NET Core to download and install.
Options: 2.1, 2.2, 3.0, 3.1, 5.0, 6.0
useProxy
Use a proxy server
Enabling this option will make it possible to specify a proxy server address that will be used to download the installer.
proxyServerAddress
Proxy server address
The URL of the proxy server to use when downloading the installer. Needs to include the port number.
Example: http://proxy.example.com:80
norestart
No Restart
Enabling this option will pass the /norestart argument to the installer to suppress any attempts to restart.
iisReset
Perform IIS reset
Enabling this option will reset IIS after installation.
The reset is recommended for all changes to take effect.
installArguments
Install arguments
Optional arguments that will be passed to the installer. Example: 'OPT_NO_ANCM=1 OPT_NO_X86=1'. See these options for more information.

Examples

YAML pipeline

  1. Install the Install .NET Core Runtime & Hosting Bundle extension from the Marketplace in your Azure DevOps organization.
  2. Create a new Environment with the name 'net-core-test'. Select 'Virtual machines' as the resource type.
  3. Register a machine in the new Environment and give it the tag 'net-core'.
  4. Create a new YAML pipeline with the following content.
trigger: none

stages:
- stage: 'InstallNetCore'
  jobs:
  - deployment: 'InstallNetCore'
    environment:
      name: 'net-core-test'
      resourceType: 'VirtualMachine'
      tags: 'net-core'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: InstallNetCoreRuntimeAndHosting@1
            inputs:
              version: '3.1'
              useProxy: false
              norestart: false
              iisReset: true
  1. Save and run the pipeline.

Release pipeline with a Deployment group job

  1. Install the Install .NET Core Runtime & Hosting Bundle extension from the Marketplace in your Azure DevOps organization.

  2. Create a Deployment group.

  3. Register a machine in the new Deployment group.

  4. Create a new Release pipeline.

  5. Add a Deployment group job for the new Deployment group.

  6. Add the Install .NET Core Runtime & Hosting Bundle task to the Deployment group job.

  7. Configure the version you want to install.

    Release Pipeline Example

  8. Save and run the pipeline.

Q & A

How does it work?

The task wraps a PowerShell script that:

  1. Retrieves the latest available .NET Core version from the appropriate releases.json, like https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json.
  2. Looks in the releases.json for the download URL of the .NET Core Runtime & Hosting bundle installer (dotnet-hosting-win.exe).
  3. Downloads the installer.
  4. Executes the installer.
  5. Uploads any logs created by the installer.
  6. Performs an IIS reset if specified.

The task does not use PowerShell remoting so it will download and install .NET Core on the server where the task is run.

Does it uninstall older versions of .NET Core?

No.

What OS is supported?

The .NET Core runtime and hosting bundle is only available for Windows.

What to do when I get an error downloading the installer?

In some cases you might get an error like the one below because the task is unable to download the installer.

Load release data from: https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/3.0/releases.json
Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error occurred on a receive."
At C:\azagent\A1\_work\_temp\39753a3f-3f3e-4351-b612-3d286ccd9f29.ps1:20 char:5
+     $releases = $webClient.DownloadString($releasesJSONURL) | Convert ...

There are several reasons that might cause an error like this to occur:

  • The site https://dotnetcli.blob.core.windows.net, with the releases.json that has the download URL for the installer, is not a trusted site.
  • The site https://download.visualstudio.microsoft.com/, where the installer is hosted, is not a trusted site.
  • The server does not have outgoing internet access.

Depending on the reason adding a site to the trusted sites might do the trick.

Open source

This task is open source on GitHub.

installnetcoreruntimeandhostingtask's People

Contributors

ronald-bosma avatar ronaldbosma avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

installnetcoreruntimeandhostingtask's Issues

installing net core runtime in Remote Machine

What about installing the net core runtime and hosting in a remote machine?
Do you think is possible?
I don't use Environments with Virtual Machines.
I deploy a net core app with WINRM - IIS Web App Manage/Deploy task.

Detect runtime version from global.json file

First of all thank you, this task is really a great help to ensure the server has all required software to run our app.

It would be great if it could check the required version from a global.json file in the project. This could be presented in the form of a Use global json parameter just like the Use .NET Core task.

What are your thoughts on this ?

Installing .NET 5.0.4 fails

Installing .NET 5.0.4 fails with the error: No latest release found.

The task uses this releases.json file to select the latest .NET version. The latest-release and latest-release-date fields in this JSON are used to select the correct release.

As you can see in the JSON snippet below. The date format of latest-release-date differs from the release-date of version 5.0.4. So the task can't select the latest version.

{
  "channel-version": "5.0",
  "latest-release": "5.0.4",
  "latest-release-date": "2021-03-09",
  "latest-runtime": "5.0.4",
  "latest-sdk": "5.0.201",
  "support-phase": "current",
  "lifecycle-policy": "https://dotnet.microsoft.com/platform/support/policy/",
  "releases": [
    {
      "release-date": "2021-09-03",
      "release-version": "5.0.4",

Detect if runtime is installed before download

Great task. Worked like a charm right out of the box!

It takes about 30-45 seconds and quite a bit of bandwidth to download the installer. For a continuous deployment pipeline this is a bit expensive, especially when the target environment probably is already configured correctly.

I think it would be worth checking if the desired runtime version is already installed before downloading the installer. You could also add a boolean parameter "force" to always download and run the installer regardless.

Thanks

Enable flagging for ANCM install

Great extension, but I'd like an option to install the ASP.NET Core Module for IIS as there is no way to install outside the hosting bundle. Could be good to add options for any of the opt-out parameters.

OPT_NO_ANCM=1 (Skip ANCM install)
OPT_NO_RUNTIME=1 (Skip .NET Core runtime install)
OPT_NO_SHAREDFX=1 (Skip ASP.NET Shared framework, aka ASP.NET runtime install)
OPT_NO_X86=1 (Skip install x86 runtimes, ancm on 64-bit OS)

https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.1#install-the-hosting-bundle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.