Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for installing latest build from main to scripts and update docs. #4682

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions docs/using-latest-daily.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,32 @@ These instructions will get you set up with the latest build of Aspire. If you j

See [machine-requirements.md](machine-requirements.md).

## Add necessary NuGet feeds

The latest builds are pushed to a special feed, which you need to add:
```sh
dotnet nuget add source --name dotnet8 https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
```

As usual this will add the feed to any existing NuGet.config in the directory or above, or else in the global NuGet.config. See [configuring NuGet behavior](https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior) to read more about that.
## Run the workload installation script

Alternatively, if you are using Visual Studio, you can [Install and manage packages in Visual Studio](https://learn.microsoft.com/nuget/consume-packages/install-use-packages-visual-studio#package-sources) and add the feed `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json` there.
The [workload installation script](./../eng/installLatestFromReleaseBranch.ps1)) will install the latest .NET Aspire workload from the release branch, but it can also install latest from main (latest nightly build) if the `-FromMain` flag is used (`--fromMain` on Linux/macOS).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should I choose? Something like "The main branch will generally have the most recent code, while the release branch will generally have been more tested."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reality, nowadays you really only want -FromMain always, as the script doesn't work with stable builds, and since all of the builds out of our release branch are stable now, it means the release branches support doesn't work now. I think the way forward is that the script should be changed such that the default (without params) installs you latest build from main, and if you specify a flag we instead install you the latest GA build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can either do that in this PR or as a follow up. Since I'll be out for two weeks and some people might benefit from this today, I tempted to push support for main now and then as a follow up fix the scripts to support the above.


## Install the .NET Aspire dotnet workload
### Windows

First, we need to make sure you have the latest version of the workload manifest in your sdk. You can do this by running:
From a powershell prompt, and from the root of the aspire repo, run:

```shell
dotnet workload update --skip-sign-check --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
.\eng\installLatestFromReleaseBranch.ps1 -FromMain
```
If you are already on the latest version, then the command is a no-op.

Then, we are now able to install the workload with the version of the manifest that we just updated.
### Linux/macOS

```shell
dotnet workload install aspire --skip-sign-check --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
```
From a terminal, and from the root of the aspire repo, run:

To update it later if you wish
```shell
dotnet workload update --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
./eng/installLatestFromReleaseBranch.sh --fromMain
```

Now you are ready to create and run an Aspire app using these latest Aspire components.
## Add necessary NuGet feeds

The latest builds are pushed to a special feed, which you need to add:
```sh
dotnet nuget add source --name dotnet8 https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json
```

## Create a new Project

Expand Down Expand Up @@ -66,15 +60,7 @@ dotnet run --project "<directoryname>.AppHost"

Alternatively, if you are using Visual Studio, you can instead create a new Blazor Web App project and check the `Enlist in Aspire orchestration` box while creating it. Then use <kbd>F5</kbd> to debug or <kbd>Ctrl+F5</kbd> to launch without debugging.

## [Optional] Using scripts to install the latest .NET Aspire build from release branches

If you want to install the latest build from the main branch, then you shouldn't follow the next steps, and instead check out: [Add necessary NuGet feeds](#add-necessary-nuget-feeds).

If you want to use the latest .NET Aspire build from release branches, you can use the scripts in this repo to install the latest .NET Aspire build from those. The reason why we provide scripts for builds from release branches but not for main, is that when working with dotnet workloads, it is not easy to specify exactly which version of the workload you want to install, and instead you get the latest NuGet package version that the SDK is able to find in your configured NuGet feeds. For release branches though, this will not work as main branch produces packages like 8.0.0-preview.x, while release branches produce packages like 8.0.0-preview.(x-1). For example, when main produces packages with version 8.0.0-preview.3, release branches produce packages with version 8.0.0-preview.2.

The scripts to install these builds, are [installLatestFromReleaseBranch.ps1](../eng/installLatestFromReleaseBranch.ps1) for Windows, and [installLatestFromReleaseBranch.sh](../eng/installLatestFromReleaseBranch.sh) for Linux and macOS. These scripts will use rollback files, which at this time is the only way to specify which exact version of a workload you want to install. They will query the feed that contains all of the builds from the release branch, get the latest version, and generate a rollback file to be used for the installation. Finally, it will run the workload `update` and `install` commands for you, using the rollback file. Note that these scripts will work even if you already have a different version of the workload installed, independently of whether it is an older or newer version, and it will override it with the one calculated from the script.

### Troubleshooting
## Troubleshooting

Potential issues that may happen when using these scripts:

Expand Down
47 changes: 41 additions & 6 deletions eng/installLatestFromReleaseBranch.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# NuGet Feed URL
param (
[switch]$FromMain,
[switch]$Help
)

function Show-Help {
Write-Output "Usage: .\script.ps1 [-FromMain] [-Help]"
Write-Output ""
Write-Output "Options:"
Write-Output " -FromMain Get the latest build from main branch (default: latest build from the release branch)."
Write-Output " -Help Display this help message and exit."
}

if ($Help) {
Show-Help
exit
}

# Default NuGet Feed URL
$nugetUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"

# Update NuGet Feed URL if -FromMain is specified
if ($FromMain) {
$nugetUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
}

# Package name to search for
$packageName = "Microsoft.NET.Sdk.Aspire.Manifest-8.0.100"

Expand All @@ -26,14 +49,26 @@ $fileContent = @"
# Write to file
$fileContent | Out-File -FilePath "aspire-rollback.txt"

# Run dotnet workload update command
dotnet workload update --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" --skip-sign-check --from-rollback-file .\aspire-rollback.txt
# Run dotnet workload update command with optional --include-previews parameter
$updateCommand = "dotnet workload update --source $nugetUrl --skip-sign-check --from-rollback-file .\aspire-rollback.txt"
if ($FromMain) {
$updateCommand += " --include-previews"
}
Invoke-Expression $updateCommand

# Run dotnet workload install command
dotnet workload install aspire --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" --skip-sign-check --from-rollback-file .\aspire-rollback.txt
# Run dotnet workload install command with optional --include-previews parameter
$installCommand = "dotnet workload install aspire --source $nugetUrl --skip-sign-check --from-rollback-file .\aspire-rollback.txt"
if ($FromMain) {
$installCommand += " --include-previews"
}
Invoke-Expression $installCommand

# Delete the rollback file as it is no longer needed.
Remove-Item "aspire-rollback.txt" -Force

# Output the latest version
Write-Output "Installed Latest version of aspire produced from the release branch. Version installed was $latestVersion."
if ($FromMain) {
Write-Output "Installed Latest version of .NET Aspire produced from the main branch. Version installed was $latestVersion."
} else {
Write-Output "Installed Latest version of .NET Aspire produced from the release branch. Version installed was $latestVersion."
}
53 changes: 47 additions & 6 deletions eng/installLatestFromReleaseBranch.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# Function to display usage information
show_help() {
echo "Usage: $0 [--fromMain] [--help]"
echo ""
echo "Options:"
echo " --fromMain Get the latest build from main branch (default: latest build from the release branch)."
echo " --help Display this help message and exit."
}

# Check if jq is installed
if ! command -v jq &> /dev/null
then
Expand All @@ -9,9 +18,29 @@ then
exit 1
fi

# NuGet Feed URL
# Default NuGet Feed URL
nugetUrl="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"

# Check for script arguments
fromMain=false
for arg in "$@"; do
case $arg in
--fromMain)
fromMain=true
nugetUrl="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"
;;
--help)
show_help
exit 0
;;
*)
echo "Unknown option: $arg"
show_help
exit 1
;;
esac
done

# Package name to search for
packageName="Microsoft.NET.Sdk.Aspire.Manifest-8.0.100"

Expand All @@ -38,14 +67,26 @@ END
# Write to file
echo "$fileContent" > aspire-rollback.txt

# Run dotnet workload update command
dotnet workload update --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" --skip-sign-check --from-rollback-file ./aspire-rollback.txt
# Run dotnet workload update command with optional --include-previews parameter
updateCommand="dotnet workload update --source $nugetUrl --skip-sign-check --from-rollback-file ./aspire-rollback.txt"
if [ "$fromMain" = true ]; then
updateCommand+=" --include-previews"
fi
eval $updateCommand

# Run dotnet workload install command
dotnet workload install aspire --source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" --skip-sign-check --from-rollback-file ./aspire-rollback.txt
# Run dotnet workload install command with optional --include-previews parameter
installCommand="dotnet workload install aspire --source $nugetUrl --skip-sign-check --from-rollback-file ./aspire-rollback.txt"
if [ "$fromMain" = true ]; then
installCommand+=" --include-previews"
fi
eval $installCommand

# Delete the rollback file as it is no longer needed.
rm -f ./aspire-rollback.txt

# Output the latest version
echo "Installed Latest version of aspire produced from the release branch. Version installed was $latestVersion."
if [ "$fromMain" = true ]; then
echo "Installed Latest version of .NET Aspire produced from the main branch. Version installed was $latestVersion."
else
echo "Installed Latest version of .NET Aspire produced from the release branch. Version installed was $latestVersion."
fi
Loading