Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 1bb1d15

Browse files
authored
update dev environments feature branch with latest idl changes (#2334)
* update feature branch to latest sdk * update InputJson to inputJson * update with latest changes
1 parent c4c71cf commit 1bb1d15

35 files changed

+1016
-851
lines changed

HyperVExtension/src/DevSetupEngine/ConfigurationFileHelper.cs

Lines changed: 204 additions & 204 deletions
Large diffs are not rendered by default.

HyperVExtension/src/HyperVExtension/CommunicationWithGuest/ApplyConfigurationOperation.cs

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,46 @@
44
using System.ComponentModel;
55
using System.Globalization;
66
using System.Runtime.InteropServices;
7+
using System.Runtime.InteropServices.WindowsRuntime;
78
using System.Threading;
89
using HyperVExtension.HostGuestCommunication;
10+
using HyperVExtension.Models;
911
using HyperVExtension.Providers;
1012
using Microsoft.Windows.DevHome.SDK;
1113
using Windows.Foundation;
14+
using Windows.Storage;
15+
using Windows.Storage.Streams;
1216
using Windows.Win32.Foundation;
13-
1417
using SDK = Microsoft.Windows.DevHome.SDK;
1518

1619
namespace HyperVExtension.CommunicationWithGuest;
1720

18-
internal sealed class ApplyConfigurationOperation : IApplyConfigurationOperation, IDisposable
21+
public sealed class ApplyConfigurationOperation : IApplyConfigurationOperation, IDisposable
1922
{
20-
private readonly IComputeSystem _computeSystem;
23+
private readonly HyperVVirtualMachine _virtualMachine;
2124
private readonly CancellationTokenSource _cancellationTokenSource = new();
25+
2226
private bool _disposed;
2327

24-
public ApplyConfigurationOperation(IComputeSystem computeSystem)
28+
public string Configuration { get; private set; } = string.Empty;
29+
30+
public ApplyConfigurationOperation(HyperVVirtualMachine virtualMachine, string configuration)
2531
{
26-
_computeSystem = computeSystem;
32+
_virtualMachine = virtualMachine;
33+
Configuration = configuration;
2734
}
2835

29-
public ApplyConfigurationOperation(IComputeSystem computeSystem, Exception result, string? resultDescription = null)
36+
public ApplyConfigurationOperation(HyperVVirtualMachine virtualMachine, Exception result, string? resultDescription = null)
3037
{
31-
_computeSystem = computeSystem;
32-
CompletionStatus = new SDK.ApplyConfigurationResult(
33-
result,
34-
resultDescription,
35-
null,
36-
null);
38+
_virtualMachine = virtualMachine;
39+
CompletionStatus = new SDK.ApplyConfigurationResult(result, result.Message, result.Message);
3740
}
3841

3942
public CancellationToken CancellationToken => _cancellationTokenSource.Token;
4043

41-
public event TypedEventHandler<IComputeSystem, SDK.ApplyConfigurationResult>? Completed;
44+
public event TypedEventHandler<IApplyConfigurationOperation, ApplyConfigurationActionRequiredEventArgs> ActionRequired = (s, e) => { };
4245

43-
public event TypedEventHandler<IComputeSystem, SDK.ConfigurationSetChangeData>? Progress;
46+
public event TypedEventHandler<IApplyConfigurationOperation, ConfigurationSetStateChangedEventArgs> ConfigurationSetStateChanged = (s, e) => { };
4447

4548
public SDK.ApplyConfigurationResult? CompletionStatus { get; private set; }
4649

@@ -50,45 +53,45 @@ public ApplyConfigurationOperation(IComputeSystem computeSystem, Exception resul
5053
SDK.ConfigurationSetState.Unknown,
5154
SDK.ConfigurationUnitState.Unknown,
5255
new SDK.ConfigurationUnitResultInformation(null, null, null, SDK.ConfigurationUnitResultSource.None),
53-
new SDK.ConfigurationUnit(null, null, SDK.ConfigurationUnitState.Unknown, false, null, null, SDK.ConfigurationUnitIntent.Unknown),
54-
null);
56+
new SDK.ConfigurationUnit(null, null, SDK.ConfigurationUnitState.Unknown, false, null, null, SDK.ConfigurationUnitIntent.Unknown));
5557

56-
public void Cancel() => throw new NotImplementedException();
57-
58-
public void SetState(
58+
public void SetProgress(
5959
SDK.ConfigurationSetState state,
6060
HostGuestCommunication.ConfigurationSetChangeData? progressData,
61-
HostGuestCommunication.ApplyConfigurationResult? completionStatus,
6261
SDK.IExtensionAdaptiveCardSession2? adaptiveCardSession)
6362
{
64-
var sdkProgressData = GetSdkProgressData(state, progressData, adaptiveCardSession);
63+
var sdkProgressData = GetSdkProgressData(state, progressData);
6564

6665
if (sdkProgressData != null)
6766
{
6867
ProgressData = sdkProgressData;
69-
Progress?.Invoke(_computeSystem, ProgressData);
68+
ConfigurationSetStateChanged?.Invoke(this, new(ProgressData));
7069
}
7170

72-
// If the completionStatus is not null, then the operation is completed.
73-
if ((completionStatus != null) || (state == SDK.ConfigurationSetState.Completed))
71+
if (adaptiveCardSession != null)
7472
{
75-
var sdkCompletionStatus = GetSdkConfigurationResult(completionStatus);
76-
if (sdkCompletionStatus == null)
77-
{
78-
// No apply configuration result was provided, but state is "Completed"
79-
// so create ApplyConfigurationResult with no error (meaning operation is completed).
80-
sdkCompletionStatus = new SDK.ApplyConfigurationResult(null, null, null, null);
81-
}
73+
ActionRequired?.Invoke(this, new(adaptiveCardSession));
74+
}
75+
}
8276

83-
CompletionStatus = sdkCompletionStatus;
84-
Completed?.Invoke(_computeSystem, CompletionStatus);
77+
public SDK.ApplyConfigurationResult CompleteOperation(HostGuestCommunication.ApplyConfigurationResult? completionStatus)
78+
{
79+
// If the completionStatus is not null, then the operation is completed.
80+
// if ((completionStatus != null) || (state == SDK.ConfigurationSetState.Completed))
81+
var sdkCompletionStatus = GetSdkConfigurationResult(completionStatus);
82+
if (sdkCompletionStatus == null)
83+
{
84+
// No apply configuration result was provided, but state is "Completed"
85+
// so create ApplyConfigurationResult with no error (meaning operation is completed).
86+
sdkCompletionStatus = new SDK.ApplyConfigurationResult(null, null);
8587
}
88+
89+
return sdkCompletionStatus;
8690
}
8791

8892
private SDK.ConfigurationSetChangeData GetSdkProgressData(
8993
SDK.ConfigurationSetState state,
90-
HostGuestCommunication.ConfigurationSetChangeData? progressData,
91-
SDK.IExtensionAdaptiveCardSession2? adaptiveCardSession)
94+
HostGuestCommunication.ConfigurationSetChangeData? progressData)
9295
{
9396
SDK.ConfigurationSetChangeData sdkProgressData;
9497
if (progressData != null)
@@ -114,8 +117,7 @@ private SDK.ConfigurationSetChangeData GetSdkProgressData(
114117
(SDK.ConfigurationSetState)progressData.SetState,
115118
(SDK.ConfigurationUnitState)progressData.UnitState,
116119
resultInfo,
117-
sdkUnit,
118-
adaptiveCardSession);
120+
sdkUnit);
119121
}
120122
else
121123
{
@@ -124,8 +126,7 @@ private SDK.ConfigurationSetChangeData GetSdkProgressData(
124126
state,
125127
SDK.ConfigurationUnitState.Unknown,
126128
null,
127-
null,
128-
adaptiveCardSession);
129+
null);
129130
}
130131

131132
return sdkProgressData;
@@ -188,13 +189,15 @@ private SDK.ConfigurationSetChangeData GetSdkProgressData(
188189
sdkUnitResults.AsReadOnly());
189190
}
190191

191-
return new SDK.ApplyConfigurationResult(
192-
completionStatus.ResultCode == HRESULT.S_OK ?
193-
null :
194-
new HResultException(completionStatus.ResultCode),
195-
completionStatus.ResultDescription,
196-
sdkOpenConfigurationSetResult,
197-
sdkApplyConfigurationSetResult);
192+
var wasConfigurationSuccessful = completionStatus.ResultCode == HRESULT.S_OK;
193+
if (wasConfigurationSuccessful)
194+
{
195+
return new SDK.ApplyConfigurationResult(sdkOpenConfigurationSetResult, sdkApplyConfigurationSetResult);
196+
}
197+
198+
var hresultException = new HResultException(completionStatus.ResultCode);
199+
200+
return new SDK.ApplyConfigurationResult(hresultException, completionStatus.ResultDescription, hresultException.Message);
198201
}
199202

200203
return null;
@@ -252,4 +255,12 @@ private void Dispose(bool disposing)
252255
_disposed = true;
253256
}
254257
}
258+
259+
public IAsyncOperation<SDK.ApplyConfigurationResult> StartAsync()
260+
{
261+
return Task.Run(() =>
262+
{
263+
return _virtualMachine.ApplyConfiguration(this);
264+
}).AsAsyncOperation();
265+
}
255266
}

HyperVExtension/src/HyperVExtension/Extensions/ServiceExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static IServiceCollection AddHyperVExtensionServices(this IServiceCollect
2626
// Pattern to allow multiple non-service registered interfaces to be used with registered interfaces during construction.
2727
services.AddSingleton<IPowerShellService>(psService =>
2828
ActivatorUtilities.CreateInstance<PowerShellService>(psService, new PowerShellSession()));
29+
services.AddSingleton<HyperVVirtualMachineFactory>(sp => psObject => ActivatorUtilities.CreateInstance<HyperVVirtualMachine>(sp, psObject));
2930

3031
return services;
3132
}
Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,87 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
<Import Project="$(SolutionDir)ToolingVersions.props" />
3-
<PropertyGroup>
4-
<OutputType>Library</OutputType>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<BuildRing Condition="'$(BuildRing)'==''">Dev</BuildRing>
8-
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
9-
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<PackageReference Include="MessageFormat" Version="6.0.2" />
13-
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$(SolutionDir)ToolingVersions.props" />
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<BuildRing Condition="'$(BuildRing)'==''">Dev</BuildRing>
8+
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="MessageFormat" Version="6.0.2" />
13+
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
1414
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.0" />
1515
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
16-
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
17-
<PrivateAssets>all</PrivateAssets>
18-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19-
</PackageReference>
20-
<PackageReference Include="Microsoft.Windows.DevHome.SDK" Version="0.1099.421.2021" />
21-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231115000" />
22-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
23-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
24-
<PackageReference Include="System.Management.Automation" Version="7.4.0" />
25-
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
26-
</ItemGroup>
27-
28-
<ItemGroup>
29-
<ProjectReference Include="..\HyperVExtension.Common\HyperVExtension.Common.csproj" />
30-
<ProjectReference Include="..\HyperVExtension.HostGuestCommunication\HyperVExtension.HostGuestCommunication.csproj" />
31-
<ProjectReference Include="..\Logging\HyperVExtension.Logging.csproj" />
32-
<ProjectReference Include="..\Telemetry\HyperVExtension.Telemetry.csproj" />
33-
</ItemGroup>
34-
35-
<ItemGroup>
36-
<PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
37-
<PrivateAssets>all</PrivateAssets>
38-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
39-
</PackageReference>
40-
</ItemGroup>
41-
42-
<!--
43-
Copy DevSetupAgent_<Patform>.zip to the output directory so it picked up by MSIX packaging.
44-
If building from the build script the zip file should exist as it's created as part of the script execution.
45-
VS currently doesn't have a task to create it and it may not exist if it wasn't previously created by the build script.
46-
We will not treat that as an error for now.
47-
If building Dev Home for x64 or x86 paltforms DevSetupAgent will be built only as x86 to reduce package size.
48-
x86 binaries can be deployed on both x64 and x86 VMs.
49-
-->
50-
<ItemGroup>
51-
<None Include="..\DevSetupAgent\bin\DevSetupAgent_x86.zip"
52-
Condition="('$(Platform)'=='x64' or '$(Platform)'=='x86') and ('$(BuildingInsideVisualStudio)' != 'True' or Exists('..\HyperVExtension\src\DevSetupAgent\bin\DevSetupAgent_x86.zip'))">
53-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
54-
</None>
55-
<None Include="..\DevSetupAgent\bin\DevSetupAgent_arm64.zip"
56-
Condition="'$(Platform)'=='arm64' and ('$(BuildingInsideVisualStudio)' != 'True' or Exists('..\HyperVExtension\src\DevSetupAgent\bin\DevSetupAgent_arm64.zip'))">
57-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
58-
</None>
59-
</ItemGroup>
60-
61-
<PropertyGroup>
62-
<DefineConstants Condition="'$(BuildRing)'=='Canary'">$(DefineConstants);CANARY_BUILD</DefineConstants>
63-
<DefineConstants Condition="'$(BuildRing)'=='Stable'">$(DefineConstants);STABLE_BUILD</DefineConstants>
64-
</PropertyGroup>
65-
66-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67-
<DebugType>portable</DebugType>
68-
</PropertyGroup>
69-
70-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
71-
<DebugType>portable</DebugType>
72-
</PropertyGroup>
73-
74-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
75-
<DebugType>portable</DebugType>
76-
</PropertyGroup>
77-
78-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
79-
<DebugType>portable</DebugType>
80-
</PropertyGroup>
81-
82-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
83-
<DebugType>portable</DebugType>
84-
</PropertyGroup>
85-
86-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
87-
<DebugType>portable</DebugType>
88-
</PropertyGroup>
89-
</Project>
16+
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.49-beta">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
<PackageReference Include="Microsoft.Windows.DevHome.SDK" Version="0.1199.424.2036" />
21+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231115000" />
22+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
23+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
24+
<PackageReference Include="System.Management.Automation" Version="7.4.0" />
25+
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<ProjectReference Include="..\HyperVExtension.Common\HyperVExtension.Common.csproj" />
30+
<ProjectReference Include="..\HyperVExtension.HostGuestCommunication\HyperVExtension.HostGuestCommunication.csproj" />
31+
<ProjectReference Include="..\Logging\HyperVExtension.Logging.csproj" />
32+
<ProjectReference Include="..\Telemetry\HyperVExtension.Telemetry.csproj" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
37+
<PrivateAssets>all</PrivateAssets>
38+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
39+
</PackageReference>
40+
</ItemGroup>
41+
42+
<!--
43+
Copy DevSetupAgent_<Patform>.zip to the output directory so it picked up by MSIX packaging.
44+
If building from the build script the zip file should exist as it's created as part of the script execution.
45+
VS currently doesn't have a task to create it and it may not exist if it wasn't previously created by the build script.
46+
We will not treat that as an error for now.
47+
If building Dev Home for x64 or x86 paltforms DevSetupAgent will be built only as x86 to reduce package size.
48+
x86 binaries can be deployed on both x64 and x86 VMs.
49+
-->
50+
<ItemGroup>
51+
<None Include="..\DevSetupAgent\bin\DevSetupAgent_x86.zip" Condition="('$(Platform)'=='x64' or '$(Platform)'=='x86') and ('$(BuildingInsideVisualStudio)' != 'True' or Exists('..\HyperVExtension\src\DevSetupAgent\bin\DevSetupAgent_x86.zip'))">
52+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
53+
</None>
54+
<None Include="..\DevSetupAgent\bin\DevSetupAgent_arm64.zip" Condition="'$(Platform)'=='arm64' and ('$(BuildingInsideVisualStudio)' != 'True' or Exists('..\HyperVExtension\src\DevSetupAgent\bin\DevSetupAgent_arm64.zip'))">
55+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
56+
</None>
57+
</ItemGroup>
58+
59+
<PropertyGroup>
60+
<DefineConstants Condition="'$(BuildRing)'=='Canary'">$(DefineConstants);CANARY_BUILD</DefineConstants>
61+
<DefineConstants Condition="'$(BuildRing)'=='Stable'">$(DefineConstants);STABLE_BUILD</DefineConstants>
62+
</PropertyGroup>
63+
64+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
65+
<DebugType>portable</DebugType>
66+
</PropertyGroup>
67+
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
69+
<DebugType>portable</DebugType>
70+
</PropertyGroup>
71+
72+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
73+
<DebugType>portable</DebugType>
74+
</PropertyGroup>
75+
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
77+
<DebugType>portable</DebugType>
78+
</PropertyGroup>
79+
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
81+
<DebugType>portable</DebugType>
82+
</PropertyGroup>
83+
84+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
85+
<DebugType>portable</DebugType>
86+
</PropertyGroup>
87+
</Project>

0 commit comments

Comments
 (0)