Skip to content

Support for nuget packages which contain winmd files #6917

@Willaaaaaaa

Description

@Willaaaaaaa

Is your feature request related to a problem? Please describe.

This is kind of like a bug.

When you try xrepo install -vD nuget::Microsoft.Toolkit.Uwp.Notifications (This is a WinRT component). It will fail when checking for the installtion, because pkgs like this don't have .lib files, only have .winmd files (which I think caused fetch_info=nil). .winmd files need to use cppwinrt.exe to get the C++ projection files.

error message
PS C:\Users\Willaaaaaaa> xrepo install -vD nuget::Microsoft.Toolkit.Uwp.Notifications
D:\Software\xmake\xmake.exe f -c --require=n -vD
checking for platform ... windows
checking for architecture ... x64
checking for cl.exe ... D:\Software\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.50.35615\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2026
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checking for cl.exe ... D:\Software\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.50.35615\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for link.exe ... D:\Software\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.50.35615\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
configure
{
    kind = static
    builddir = build
    plat = windows
    proxy_pac = pac.lua
    clean = true
    ndk_stdcxx = true
    vs = 2026
    host = windows
    ccache = true
    mode = release
    proxy = http://127.0.0.1:7897
    theme = default
    arch = x64
    network = public
}
D:\Software\xmake\xmake.exe require -v -D -j 22 --extra={system=false} nuget::Microsoft.Toolkit.Uwp.Notifications
checking for git ... D:\Software\Git\cmd\git.exe
checkinfo: cannot runv(gzip.exe --version), No such file or directory
checking for gzip ... no
checking for 7z ... D:\Software\xmake\winenv\bin\7z
finding Microsoft.Toolkit.Uwp.Notifications from nuget ..
checking for nuget::Microsoft.Toolkit.Uwp.Notifications ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in nuget:
  -> nuget::Microsoft.Toolkit.Uwp.Notifications latest [runtimes:"MD"]
please input: y (y/n/m)

installing Microsoft.Toolkit.Uwp.Notifications from nuget ..
checking for dotnet ... C:\Program Files\dotnet\dotnet.exe
C:\Program Files\dotnet\dotnet.exe new console -n stub
已成功创建模板“控制台应用”。

正在处理创建后操作...
正在还原 C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj:
已成功还原。


C:\Program Files\dotnet\dotnet.exe add package Microsoft.Toolkit.Uwp.Notifications

在 0.5 秒内生成 已成功
info : X.509 证书链验证将使用 .NET 选择的默认信任存储进行代码签名。
info : X.509 证书链验证将使用 .NET 选择的默认信任存储进行时间戳。
info : 正在将包“Microsoft.Toolkit.Uwp.Notifications”的 PackageReference 添加到项目“C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj”。
info :   GET https://api.nuget.org/v3/registration5-gz-semver2/microsoft.toolkit.uwp.notifications/index.json
info :   OK https://api.nuget.org/v3/registration5-gz-semver2/microsoft.toolkit.uwp.notifications/index.json 347 毫秒
info : 正在还原 C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj 的包...
info :   GET https://api.nuget.org/v3/vulnerabilities/index.json
info :   OK https://api.nuget.org/v3/vulnerabilities/index.json 772 毫秒
info :   GET https://api.nuget.org/v3-vulnerabilities/2025.10.08.05.30.15/vulnerability.base.json
info :   GET https://api.nuget.org/v3-vulnerabilities/2025.10.08.05.30.15/2025.10.10.11.30.22/vulnerability.update.json
info :   OK https://api.nuget.org/v3-vulnerabilities/2025.10.08.05.30.15/vulnerability.base.json 285 毫秒
info :   OK https://api.nuget.org/v3-vulnerabilities/2025.10.08.05.30.15/2025.10.10.11.30.22/vulnerability.update.json 744 毫秒
info : 包“Microsoft.Toolkit.Uwp.Notifications”与项目“C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj”中指定的所有框架均兼容。
info : 包“Microsoft.Toolkit.Uwp.Notifications”(版本为 7.1.3)的 PackageReference 已添加到文件“C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj”。
info : 将资产文件写入磁盘。路径: C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\obj\project.assets.json
log  : 已还原 C:\Users\Willaaaaaaa\AppData\Local\Temp\.xmake\251010\xrepo\working\build\.packages\n\nuget_microsoft.toolkit.uwp.notifications\latest\3c332be551f6485e8d17e1830ee49789\stub\stub.csproj (用时 1.69 秒)。
finding Microsoft.Toolkit.Uwp.Notifications from nuget ..
checking for nuget::Microsoft.Toolkit.Uwp.Notifications ... no

error: ...\modules\private\action\require\impl\actions\install.lua:501: fetch nuget::Microsoft.Toolkit.Uwp.Notifications-latest failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1087]: in function 'raiselevel'
    [@programdir\core\sandbox\modules\utils.lua:143]: in function 'assert'
    [...\modules\private\action\require\impl\actions\install.lua:501]:

  => install nuget::Microsoft.Toolkit.Uwp.Notifications latest .. failed
error: @programdir\core\main.lua:272: @programdir\modules\async\runjobs.lua:390: ...\modules\private\action\require\impl\actions\install.lua:581: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1087]:
    [...\modules\private\action\require\impl\actions\install.lua:581]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:439]:
    [...modules\private\action\require\impl\install_packages.lua:510]: in function 'job_func'
    [@programdir\modules\async\runjobs.lua:206]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:1087: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:272: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:514: in function <@programdir\core\base\scheduler.lua:507>
error: @programdir\core\main.lua:272: @programdir\core\sandbox\modules\os.lua:378: execv(D:\Software\xmake\xmake.exe require -v -D -j 22 --extra={system=false} nuget::Microsoft.Toolkit.Uwp.Notifications) failed(-1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1087]:
    [@programdir\core\sandbox\modules\os.lua:378]:
    [@programdir\modules\private\xrepo\action\install.lua:311]: in function '_install_packages'
    [@programdir\modules\private\xrepo\action\install.lua:318]:
    [@programdir\modules\private\xrepo\main.lua:196]:
    [@programdir\modules\utils\run_script.lua:101]: in function '_run_script'
    [@programdir\modules\utils\run_script.lua:158]: in function '_run'
    [@programdir\modules\utils\run_script.lua:207]:
    [@programdir\plugins\lua\main.lua:58]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:246]:
    [@programdir\core\base\task.lua:495]: in function 'run'
    [@programdir\core\main.lua:270]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:514]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:1087: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:272: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:514: in function <@programdir\core\base\scheduler.lua:507>

Describe the solution you'd like

I think we should add some operation when dealing with such pkgs. I don't know how to judge whether a nuget package should use cppwinrt.exe or not. But I can provide a way to get the source files. ref (some usage here maybe old): https://modernwindows.wordpress.com/2017/11/15/cppwinrt-exe-in-the-windows-sdk/

cppwinrt usage
D:\Software\Microsoft Visual Studio\2022\Community>cppwinrt

C++/WinRT v2.0.250303.1
Copyright (c) Microsoft Corporation. All rights reserved.

  cppwinrt.exe [options...]

Options:

  -input <spec>       Windows metadata to include in projection
  -reference <spec>   Windows metadata to reference from projection
  -output <path>      Location of generated projection and component templates
  -component [<path>] Generate component templates, and optional implementation
  -name <name>        Specify explicit name for component files
  -verbose            Show detailed progress information
  -overwrite          Overwrite generated component files
  -prefix             Use dotted namespace convention for component files (defaults to folders)
  -pch <name>         Specify name of precompiled header file (defaults to pch.h; use '.' to disable)
  -include <prefix>   One or more prefixes to include in input
  -exclude <prefix>   One or more prefixes to exclude from input
  -base               Generate base.h unconditionally
  -optimize           Generate component projection with unified construction support
  -help               Show detailed help with examples
  -library <prefix>   Specify library prefix (defaults to winrt)
  -license [<path>]   Generate license comment from template file
  @<path>             Response file containing command line options

Where <spec> is one or more of:

  path                Path to winmd file or recursively scanned folder
  local               Local %WinDir%\System32\WinMetadata folder
  sdk[+]              Current version of Windows SDK [with extensions]
  10.0.12345.0[+]     Specific version of Windows SDK [with extensions]

And accrording to the usage, we can get the header files for Microsoft.Toolkit.Uwp.Notifications by doing this below :

PS C:\Users\Willaaaaaaa> & 'D:\Windows Kits\10\bin\10.0.26100.0\x64\cppwinrt.exe' -input "C:\Users\Willaaaaaaa\.nuget\packages\microsoft.toolkit.uwp.notifications\7.1.3\lib\native\Microsoft.Toolkit.Uwp.Notifications.winmd" -reference sdk -output "C:\Users\Willaaaaaaa\.nuget\packages\microsoft.toolkit.uwp.notifications\7.1.3\lib\generated" -verbose
.../.nuget/packages/microsoft.toolkit.uwp.notifications/7.1.3/lib/generated$ tree .
.
└── winrt
    ├── Microsoft.Toolkit.Uwp.Notifications.h
    ├── base.h
    ├── impl
    │   ├── Microsoft.Toolkit.Uwp.Notifications.0.h
    │   ├── Microsoft.Toolkit.Uwp.Notifications.1.h
    │   └── Microsoft.Toolkit.Uwp.Notifications.2.h
    └── winrt.ixx

This looks like a header-only library.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions