Skip to content

Commit

Permalink
Merge pull request #94 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
Fixing reference / nuget bugs
  • Loading branch information
Psychlist1972 authored Jul 1, 2023
2 parents 2bfa8e2 + b49a505 commit 8fbc586
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,28 @@ When run outside the tools, you'll need to be prepared to either use a packaged
| Appx/MSIX Packaged Desktop C++ / WinRT App | No | No | Yes | No |
| Appx/MSIX Packaged Desktop .NET / WinRT App | No | Yes | No | No |

### Problem locating header files

If your project cannot resolve the header files, you may be running into [this bug](https://github.com/microsoft/cppwinrt/issues/593). That bug should be fixed, but there are instances, it seems, where it still crops up. If that happens, and you've verified that it's not a problem with the WinMD missing from your project (it's more typically an issue with a reference), you can add `$(GeneratedFilesDir)` to the include path for your project.

CPPWinRT.exe creates the winrt/namespace-name.h files in the Generated Files/winrt folder based upon the referenced winmd.

## Consuming from C++

Add the C++/WinRT Nuget package to your C++ project in Visual Studio. This installs the required tools and build process. See the C++/WinRT FAQ link below for using LLVM/Clang. Note that the Windows MIDI Services team does not provide any support for LLVM/Clang, but we will take PRs as required if we need to change something reasonable to ensure you are successful with those tools, within what C++/WinRT can support.

Download the compiled winmd packages from Github (see releases for the latest).
Download the NuGet package for the Core SDK

* Until this is published on NuGet.org, you'll need to set up a local package repository. This is easy to do inside the NuGet Package Manager in Visual Studio. You simply point to a folder. The structure I use in the local clone of the repo is /publish for all NuGet packages

Modify the project file as required (info in the C++/WinRT docs, and you can also look at the sample application code). If you are not using Visual Studio as your toolchain for your project, you may want to pull out the MIDI code into a library in your project which does. It's not strictly required, but it's much easier. (If you do not want to do this, you'll need to manually set up the cppwinrt tools as part of your build process).
The next step will become unnecessary once the package structure is sorted. It's a silly step, and restricts you to a single architecture at the moment, but needed right now.

* Right-click the project in Visual Studio, and add a reference
* Browse to the packages folder for your project, and into the folder for the NuGet package you installed
* Navigate to the runtimes\win10-x64\native folder
* Add the reference to the .winmd from there. Both the .winmd and the .dll are located in that same folder, which is important. If the files are not side by side, type activation will fail.

If needed, modify the project file as required (info in the C++/WinRT docs, and you can also look at the sample application code). If you are not using Visual Studio as your toolchain for your project, you may want to pull out the MIDI code into a library in your project which does. It's not strictly required, but it's much easier. (If you do not want to do this, you'll need to manually set up the cppwinrt tools as part of your build process).

> Tip: you can look at the SDK tests for up-to-date project files which target the SDKs in the same solution
Expand All @@ -67,6 +82,8 @@ After that, you reference the types as you would anything else in C++. Only the

## Consuming from C# Desktop App

Please note any .NET-specifics called out in the package release. Some early packages do not support C#/ .NET.

Your project will currently need to target .NET 7 or above. We are considering support for .NET Framework and lower versions of .NET like .NET 6. However, that is neither confirmed nor promised.

Releases will eventually be in the official Nuget.org package source. For now, you can create a local package source and place the NuGet package in there. Then add it to your package sources in the NuGet Package Manager in Visual Studio.
Expand Down
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.Devices.Midi2.Core" version="1.0.0-preview.1-0046" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.220531.1" targetFramework="native" />
<package id="Microsoft.Devices.Midi2.Core" version="1.0.0-preview.1-0064" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.230524.4" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.props" Condition="Exists('packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.props')" />
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
Expand All @@ -10,8 +12,9 @@
<ProjectGuid>{fb9d8e00-e6e5-42fa-93b5-efe40dc66c04}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>sdk_client_basics</RootNamespace>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.20348.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.20348.0</WindowsTargetPlatformMinVersion>
<CppWinRTEnableDefaultCopyLocalFalse>true</CppWinRTEnableDefaultCopyLocalFalse>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
Expand All @@ -23,10 +26,6 @@
<Configuration>Debug</Configuration>
<Platform>ARM64EC</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
Expand All @@ -35,10 +34,6 @@
<Configuration>Release</Configuration>
<Platform>ARM64EC</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
Expand Down Expand Up @@ -77,6 +72,24 @@
<Import Project="PropertySheet.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64EC'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
Expand All @@ -97,11 +110,6 @@
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64EC'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -138,21 +146,26 @@
<ItemGroup>
<None Include="packages.config" />
<None Include="PropertySheet.props" />
<Text Include="readme.txt">
<DeploymentContent>false</DeploymentContent>
</Text>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Devices.Midi2">
<HintPath>packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\runtimes\win10-x64\native\Microsoft.Devices.Midi2.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
</Reference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\..\..\src\app-dev-sdk\packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0046\build\native\Microsoft.Devices.Midi2.Core.targets" Condition="Exists('..\..\..\..\..\..\src\app-dev-sdk\packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0046\build\native\Microsoft.Devices.Midi2.Core.targets')" />
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.targets" Condition="Exists('packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.220531.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\..\..\..\..\src\app-dev-sdk\packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0046\build\native\Microsoft.Devices.Midi2.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\src\app-dev-sdk\packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0046\build\native\Microsoft.Devices.Midi2.Core.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.230524.4\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.props'))" />
<Error Condition="!Exists('packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\build\native\Microsoft.Devices.Midi2.Core.targets'))" />
</Target>
</Project>
21 changes: 0 additions & 21 deletions src/app-dev-sdk/midi-sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Satellite SDKs", "Satellite
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{7EB712A7-A3CA-49D3-9055-73AA871DAF35}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk-client-basics", "..\..\get-started\midi-developers\app-developers\samples\cpp-winrt\sdk-client-basics\sdk-client-basics.vcxproj", "{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{C3CA25F0-BEC6-4828-9321-C07BF649C2E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{7D5B581F-CDE7-40F2-8A9E-E640008227EE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk-core-cpp-winrt-tests", "sdk-core-cpp-winrt-tests\sdk-core-cpp-winrt-tests.vcxproj", "{8199DE11-CC7D-4546-97A7-F771A7544046}"
Expand Down Expand Up @@ -196,22 +192,6 @@ Global
{2704528E-6E20-4B1B-A139-2C8A8E982930}.Release|ARM64EC.Build.0 = Release|Any CPU
{2704528E-6E20-4B1B-A139-2C8A8E982930}.Release|x64.ActiveCfg = Release|x64
{2704528E-6E20-4B1B-A139-2C8A8E982930}.Release|x64.Build.0 = Release|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|Any CPU.ActiveCfg = Debug|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|Any CPU.Build.0 = Debug|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|ARM64.Build.0 = Debug|ARM64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|ARM64EC.Build.0 = Debug|ARM64EC
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|x64.ActiveCfg = Debug|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Debug|x64.Build.0 = Debug|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|Any CPU.ActiveCfg = Release|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|Any CPU.Build.0 = Release|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|ARM64.ActiveCfg = Release|ARM64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|ARM64.Build.0 = Release|ARM64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|ARM64EC.ActiveCfg = Release|ARM64EC
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|ARM64EC.Build.0 = Release|ARM64EC
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|x64.ActiveCfg = Release|x64
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04}.Release|x64.Build.0 = Release|x64
{8199DE11-CC7D-4546-97A7-F771A7544046}.Debug|Any CPU.ActiveCfg = Debug|x64
{8199DE11-CC7D-4546-97A7-F771A7544046}.Debug|Any CPU.Build.0 = Debug|x64
{8199DE11-CC7D-4546-97A7-F771A7544046}.Debug|ARM64.ActiveCfg = Debug|ARM64
Expand Down Expand Up @@ -242,7 +222,6 @@ Global
{67F25A4C-E651-4739-8B13-8F454CD57B4A} = {68F4A0F4-F443-47C4-A850-2BAA0FF43E75}
{236E1240-6005-4909-9088-92A12015AECF} = {68F4A0F4-F443-47C4-A850-2BAA0FF43E75}
{2704528E-6E20-4B1B-A139-2C8A8E982930} = {68F4A0F4-F443-47C4-A850-2BAA0FF43E75}
{FB9D8E00-E6E5-42FA-93B5-EFE40DC66C04} = {C3CA25F0-BEC6-4828-9321-C07BF649C2E6}
{8199DE11-CC7D-4546-97A7-F771A7544046} = {7D5B581F-CDE7-40F2-8A9E-E640008227EE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
Loading

0 comments on commit 8fbc586

Please sign in to comment.