Skip to content

Commit

Permalink
Update to .NET SDK 9 for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Jan 24, 2025
1 parent c676360 commit 2009e51
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
name: "Build"
runs-on: windows-2022
env:
DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE: true
DOTNET_NOLOGO: true
steps:
- name: Clone source
Expand All @@ -24,7 +25,7 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Get .NET information
run: dotnet --info
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
name: "Build"
runs-on: windows-2022
env:
DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE: true
DOTNET_NOLOGO: true
steps:
- name: Clone source
Expand All @@ -26,7 +27,7 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Get .NET information
run: dotnet --info
Expand Down
38 changes: 1 addition & 37 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ as the only supported IDE environment (others like Resharper should work, though
You will need the following software installed:

* .NET Framework 4.7.2 or later (part of the Windows OS)
* [.NET SDK 8.0](https://dotnet.microsoft.com/download/dotnet/8.0)
* [.NET SDK 9.0](https://dotnet.microsoft.com/download/dotnet/9.0)
* [.NET 6.0 Runtime](https://dotnet.microsoft.com/download/dotnet/6.0)
* [git](https://git-scm.com/downloads)
* PowerShell (or [PowerShell Core](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-6))
Expand Down Expand Up @@ -40,39 +40,3 @@ Ensure that you have configured PowerShell to be able to run local unsigned scri
You can get a list of options:

`./build --help`

## Debugging

Debugging the VS Adapter is tricky. There are two ways to do it depending on whether you want to do it under `net472` or `net6.0`. In all cases, you'll currently need to build your own test adapter NuGet package using `./build.ps1 Build` first to ensure you have local symbols. The symbols are not in the public package. It's helpful to add it to a local `\packages` directory and then use an entry like `<add key="Local Packages" value=".\packages" />` in your `NuGet.config` file to point to it. Don't forget to eventually delete it from your global profile `.nuget\packages\xunit...` when you're done.

### `net472`
Easiest thing to do is add a `launchSettings.json` file that adds the `vstest.console.exe` as a startup project and point it to an xunit dll. Something like the following (use `/listtests` if you just want to debug the discovery portion):

```json
{
"profiles": {
"vstest console": {
"executablePath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe",
"commandLineArgs": ".\\bin\\Debug\\net472\\Tests.System.Reactive.dll /TestAdapterPath:.\\bin\\Debug\\net472 /listtests",
"workingDirectory": "C:\\dev\\RxNET\\Rx.NET\\Source\\Tests.System.Reactive\\"
}
}
}
```

With that as the startup project, you can set breakpoints and then hit them. You may need to manually load symbols the first time if it's not detected automatically.

### `net6.0`

Debugging the .NET Core version of the runner is currently much more difficult. You'll need [Process Explorer](https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx) to help locate the correct process to debug. This limitation should be improved in subsequent .NET Test Platform releases.

1. Start a PowerShell console and navigate to the directory with your test project
2. Set an environment variable in that console session: `$env:VSTEST_HOST_DEBUG = 1`
3. Build your test project: `dotnet build`
4. Have VS open with the xUnit solution loaded
5. Have Process Explorer open and in Tree View mode. You may want to update the "highlight delay" settings to 2-3 settings. Defaults to 1. Make the list scroll roughly to the "d's"
6. Execute the test: `dotnet vstest .\bin\debug\net6.0\MyTest.dll` (you can use the `-lt` switch to do discovery only)
7. The test adapter will wait for about 30 seconds for you to attach a debugger. You need to look for the "lowest" `dotnet.exe` process in the tree like this: ![img](https://cloud.githubusercontent.com/assets/1427284/21454655/2ca31676-c8e8-11e6-937b-06b16d8b9254.png). In this case, the PID you're looking for is `79404`.
8. In VS, go to Debug -> Attach to Process and look for the PID (easiest to sort the column by PID). Ensure the debugger type is "Automatic" and it'll choose the CoreCLR debugger.
9. Attach and then quickly hit Continue. It should load up the adapter and related code with symbols.

2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
8 changes: 4 additions & 4 deletions tools/builder/build.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<NoWarn>$(NoWarn);CS8002</NoWarn>
<!-- <NoWarn>$(NoWarn);CS8002</NoWarn> -->
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<!-- We may not be able to upgrade Bullseye easily because we are leveraging internal APIs -->
<PackageReference Include="Bullseye" Version="3.3.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SimpleExec" Version="11.0.0" />
<PackageReference Include="SimpleExec" Version="12.0.0" />
</ItemGroup>

</Project>
8 changes: 1 addition & 7 deletions tools/builder/targets/Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ public static async Task OnExecute(BuildContext context)
.GetFiles(srcFolder, "*.nuspec", SearchOption.AllDirectories)
.ToList();

// You can't see the created package name in .NET 9+ SDK without doing detailed verbosity
var verbosity =
context.DotNetSdkVersion.Major <= 8
? context.Verbosity.ToString()
: "detailed";

// Pack the .nuspec file(s)
foreach (var nuspecFile in nuspecFiles.OrderBy(x => x))
await context.Exec("dotnet", $"pack --nologo --no-build --configuration {context.ConfigurationText} --output {context.PackageOutputFolder} --verbosity {verbosity} \"{Path.GetDirectoryName(nuspecFile)}\" -p:NuspecFile={Path.GetFileName(nuspecFile)}");
await context.Exec("dotnet", $"pack --nologo --no-build --configuration {context.ConfigurationText} --output {context.PackageOutputFolder} --verbosity {context.Verbosity} \"{Path.GetDirectoryName(nuspecFile)}\" -p:NuspecFile={Path.GetFileName(nuspecFile)} -tl:off");
}
}

0 comments on commit 2009e51

Please sign in to comment.