Skip to content

Commit

Permalink
Merge pull request #561 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
Fix several SDK issues including bad reference counting
  • Loading branch information
Psychlist1972 authored Feb 27, 2025
2 parents e203210 + 6ce498a commit 592fc72
Show file tree
Hide file tree
Showing 125 changed files with 4,926 additions and 1,077 deletions.
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"BuildCSharpSamples",
"BuildInDevelopmentServicePlugins",
"BuildInDevelopmentServicePluginsInstaller",
"BuildPowerShellProjection",
"BuildServiceAndPlugins",
"BuildServiceAndPluginsInstaller",
"BuildSettingsApp",
Expand Down Expand Up @@ -101,6 +102,7 @@
"BuildCSharpSamples",
"BuildInDevelopmentServicePlugins",
"BuildInDevelopmentServicePluginsInstaller",
"BuildPowerShellProjection",
"BuildServiceAndPlugins",
"BuildServiceAndPluginsInstaller",
"BuildSettingsApp",
Expand Down
125 changes: 118 additions & 7 deletions build/nuke_build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class Build : NukeBuild

AbsolutePath UserToolsRootFolder => SourceRootFolder / "user-tools";


AbsolutePath MidiPowerShellSolutionFolder => AppSdkSolutionFolder / "projections" / "powershell" ;
AbsolutePath MidiPowerShellStagingFolder => StagingRootFolder / "midi-powershell";


AbsolutePath MidiConsoleSolutionFolder => UserToolsRootFolder / "midi-console";
AbsolutePath MidiConsoleStagingFolder => StagingRootFolder / "midi-console";
AbsolutePath ConsoleSetupSolutionFolder => UserToolsRootFolder / "midi-console-setup";
Expand All @@ -126,6 +131,7 @@ class Build : NukeBuild

AbsolutePath SamplesCSWinRTSolutionFolder => SamplesRootFolder / "csharp-net";

MSBuildVerbosity BuildVerbosity => MSBuildVerbosity.Quiet;

string[] SdkPlatforms => new string[] { "x64", "Arm64EC" };
string[] ServiceAndApiPlatforms => new string[] { "x64", "Arm64" };
Expand Down Expand Up @@ -255,7 +261,7 @@ class Build : NukeBuild
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -353,7 +359,7 @@ class Build : NukeBuild
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -415,7 +421,7 @@ class Build : NukeBuild
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
//.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -515,7 +521,13 @@ class Build : NukeBuild
Path.Combine(solutionDir, "mididiag"),
Path.Combine(solutionDir, "midiusbinfo"),
Path.Combine(solutionDir, "midimdnsinfo"),
Path.Combine(solutionDir, @"tests\InitializationExe"),
Path.Combine(solutionDir, @"tests\Benchmarks"),
Path.Combine(solutionDir, @"tests\Offline.unittests"),
Path.Combine(solutionDir, @"tests\SdkInitialization.unittests"),
Path.Combine(solutionDir, @"tests\Service.unittests"),
/* Path.Combine(solutionDir, "midi1monitor"), */
/* Path.Combine(solutionDir, "midiksinfo"), */
};

foreach (var projectFolder in toolsDirectoriesNeedingSdkPackageUpdates)
Expand Down Expand Up @@ -557,7 +569,7 @@ class Build : NukeBuild
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
//.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -587,7 +599,8 @@ class Build : NukeBuild
.DependsOn(Prerequisites)
.DependsOn(CreateVersionIncludes)
.DependsOn(BuildConsoleApp)
//.DependsOn(BuildSettingsApp)
.DependsOn(BuildSettingsApp)
.DependsOn(BuildPowerShellProjection)
.DependsOn(BuildAndPackAllAppSDKs)
.DependsOn(BuildAppSDKToolsAndTests)
.Executes(() =>
Expand Down Expand Up @@ -620,6 +633,7 @@ class Build : NukeBuild
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -679,6 +693,7 @@ void UpdateSetupBundleInfoIncludeFile(string platform)
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -725,6 +740,7 @@ void UpdateSetupBundleInfoIncludeFile(string platform)
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -1034,6 +1050,101 @@ void UpdateSetupBundleInfoIncludeFile(string platform)
});


Target BuildPowerShellProjection => _ => _
.DependsOn(Prerequisites)
.DependsOn(BuildAndPackAllAppSDKs)
.Executes(() =>
{
var solution = MidiPowerShellSolutionFolder / "midi-powershell.sln";

// for the MIDI nuget package
NuGetTasks.NuGetInstall(_ => _
.SetProcessWorkingDirectory(MidiPowerShellSolutionFolder)
.SetPreRelease(true)
.SetSource(AppSdkNugetOutputFolder)
.SetPackageID(NugetPackageId)
.SetDependencyVersion(DependencyVersion.Highest)
);

NuGetTasks.NuGetRestore(_ => _
.SetProcessWorkingDirectory(MidiPowerShellSolutionFolder)
.SetSolutionDirectory(MidiPowerShellSolutionFolder)
.SetSource(AppSdkNugetOutputFolder)
);

// build x64 and Arm64, no Arm64EC
foreach (var platform in ToolsPlatforms)
{
string solutionDir = MidiPowerShellSolutionFolder.ToString() + @"\";

string rid = platform.ToLower() == "arm64" ? "win-arm64" : "win-x64";


//var msbuildProperties = new Dictionary<string, object>();
//msbuildProperties.Add("Platform", platform);
//msbuildProperties.Add("SolutionDir", solutionDir); // to include trailing slash
//msbuildProperties.Add("RuntimeIdentifier", rid);
////msbuildProperties.Add("NoWarn", "MSB3271"); // winmd and dll platform mismatch with Arm64EC

//Console.Out.WriteLine($"----------------------------------------------------------------------");
//Console.Out.WriteLine($"Solution: {solution}");
//Console.Out.WriteLine($"SolutionDir: {solutionDir}");
//Console.Out.WriteLine($"Platform: {platform}");
//Console.Out.WriteLine($"RID: {rid}");


DotNetTasks.DotNetBuild(_ => _
.SetProjectFile(MidiPowerShellSolutionFolder / "WindowsMidiServices.csproj")
.SetConfiguration(Configuration.Release)
.SetPublishSingleFile(false)
.SetPublishTrimmed(false)
.SetSelfContained(false)
.SetRuntime(rid)
);

// copy output to staging folder

// TODO: This doesn't deal with any localization content

var psOutputFolder = MidiPowerShellSolutionFolder / "bin" / Configuration.Release / "net8.0-windows10.0.20348.0" / rid;
//var runtimesFolder = consoleOutputFolder / "runtimes" / rid / "native";
var runtimesFolder = psOutputFolder;

var stagingFolder = MidiPowerShellStagingFolder / platform;

FileSystemTasks.CopyFileToDirectory(MidiPowerShellSolutionFolder / "WindowsMidiServices.psd1", stagingFolder, FileExistsPolicy.Overwrite, true);

FileSystemTasks.CopyFileToDirectory(psOutputFolder / "WindowsMidiServices.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "WindowsMidiServices.deps.json", stagingFolder, FileExistsPolicy.Overwrite, true);

FileSystemTasks.CopyFileToDirectory(psOutputFolder / "WinRT.Runtime.dll", stagingFolder, FileExistsPolicy.Overwrite, true);

FileSystemTasks.CopyFileToDirectory(psOutputFolder / "Microsoft.Windows.Devices.Midi2.NetProjection.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "Microsoft.Windows.SDK.NET.dll", stagingFolder, FileExistsPolicy.Overwrite, true);

FileSystemTasks.CopyFileToDirectory(psOutputFolder / "Microsoft.ApplicationInsights.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "Microsoft.Win32.Registry.AccessControl.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "Newtonsoft.Json.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.CodeDom.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Configuration.ConfigurationManager.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Diagnostics.EventLog.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.DirectoryServices.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Management.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Security.Cryptography.Pkcs.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Security.Cryptography.ProtectedData.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Security.Permissions.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(psOutputFolder / "System.Windows.Extensions.dll", stagingFolder, FileExistsPolicy.Overwrite, true);


// FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Initialization.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
// FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Initialization.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
//FileSystemTasks.CopyFileToDirectory(runtimesFolder / ns + ".winmd", stagingFolder, FileExistsPolicy.Overwrite, true);

}

});


void RestoreNuGetPackagesForCPPProject(string vcxprojFilePath, string solutionDir, string packagesConfigFullPath)
{
var projectDir = Path.GetDirectoryName(vcxprojFilePath);
Expand Down Expand Up @@ -1225,7 +1336,7 @@ void UpdatePackagesConfigForCPPProject(string configFilePath)
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
//.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);

Expand Down Expand Up @@ -1304,7 +1415,7 @@ void UpdatePackagesConfigForCPPProject(string configFilePath)
/*.SetTargets("Build") */
.SetProperties(msbuildProperties)
.SetConfiguration(Configuration.Release)
//.SetVerbosity(MSBuildVerbosity.Minimal)
.SetVerbosity(BuildVerbosity)
.EnableNodeReuse()
);
}
Expand Down
2 changes: 1 addition & 1 deletion build/staging/version/BundleInfo.wxi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Include>
<?define SetupVersionName="Customer Preview 2 Arm64" ?>
<?define SetupVersionNumber="1.0.3-preview-11.250218-1526" ?>
<?define SetupVersionNumber="1.0.3-preview-11.250226-2321" ?>
</Include>
6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public static class MidiBuildInformation
{
public const string Source = "GitHub Preview";
public const string Name = "Customer Preview 2";
public const string BuildFullVersion = "1.0.3-preview-11.250218-1526";
public const string BuildFullVersion = "1.0.3-preview-11.250226-2321";
public const string VersionMajor = "1";
public const string VersionMinor = "0";
public const string VersionRevision = "3";
public const string VersionDateNumber = "250218";
public const string VersionTimeNumber = "1526";
public const string VersionDateNumber = "250226";
public const string VersionTimeNumber = "2321";
}
}

6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#define WINDOWS_MIDI_SERVICES_BUILD_SOURCE L"GitHub Preview"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_NAME L"Customer Preview 2"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.3-preview-11.250218-1526"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.3-preview-11.250226-2321"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MAJOR L"1"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MINOR L"0"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_REVISION L"3"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250218"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"1526"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250226"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"2321"

#endif

6 changes: 2 additions & 4 deletions docs/other-developer-docs/consuming-midi-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ You will follow a similar approach to C++ using windows-rs instead of C++/WinRT.

## Consuming from C++ without Visual Studio (using cmake or other tools)

The C++/WinRT tool `cppwinrt.exe` will generate a set of standard C++ header files including `Microsoft.Windows.Devices.Midi2.h` which you can pull in and include in your project. The header file projections for WinRT types outside of `Microsoft::Windows::Devices::Midi2` are generated from the Windows SDK and included in a subfolder. When we ship Windows MIDI Services in-box in Windows, this new MIDI API will be projected in the same way as all the others in the Windows SDK.
The C++/WinRT tool `cppwinrt.exe` will generate a set of standard C++ header files including `Microsoft.Windows.Devices.Midi2.h` which you can pull in and include in your project. The header file projections for WinRT types outside of `Microsoft::Windows::Devices::Midi2` are generated from the Windows SDK and included in a subfolder.

First, install the latest Windows SDK. You can get the SDK from the [Windows Dev Center](https://developer.microsoft.com/windows/downloads/windows-sdk/)

The SDK install includes the `cppwinrt.exe` tool. For the 10.0.22621.0 version of the SDK, it is found here on my PC:
`C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64` and
`C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\arm64` . Pick the version appropriate for your development PC architecture.
The SDK install includes a version of the `cppwinrt.exe` tool. However, the latest version of this tool is [available via NuGet](https://www.nuget.org/packages/Microsoft.Windows.CppWinRT/), and is preferable to the older versions shipping in the Windows SDK. You can end up with version mismatches if you use an older version.

Normally, all SDK header files, on my PC with the 10.0.22621.0 version of the SDK installed, are located here
`C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt\winrt`
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/client-basics-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250218-1526</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250226-2321</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>false</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250218-1526" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250226-2321" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250218-1526</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250226-2321</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/loopback-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250218-1526" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250226-2321" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250218-1526" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250226-2321" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/send-speed-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250218-1526</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250226-2321</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
Loading

0 comments on commit 592fc72

Please sign in to comment.