microsoft / microsoft/win32metadata

"Microsoft.Windows.WinmdGenerator" fails from msbuild

Open
#2,155 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

With a basic `.proj` file:

```xml


net8.0
$(OutputPath)\Microsoft.Windows.Component.winmd
1.0.0.0
false

```

It does some amount of processing with a 'dotnet build':

```
> dotnet build
Determining projects to restore...
All projects are up-to-date for restore.
Microsoft.Windows.Component.Metadata ->
Scraping headers for crossarch...
Scraping constants and enums...
Writing winmd...
Winmd emitted at: \Microsoft.Windows.Component.winmd

Build succeeded.
0 Warning(s)
0 Error(s)
```

But with "msbuild" it fails:

```
> msbuild
MSBuild version 17.14.23+b0019275e for .NET Framework
Build started 11/11/2025 10:15:55 AM.

Project "Q:\source\WinMdGenerationRepro\Metadata\Microsoft.Windows.Component.Metadata\Microsoft.Windows.Component.Metadata.csproj" on node 1 (default targets).
CoreGenerateAssemblyInfo:
Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
_GenerateSourceLinkFile:
Source Link is empty, file 'obj\Debug\net8.0\Microsoft.Windows.Component.Metadata.sourcelink.json' does not exist.
CopyFilesToOutputDirectory:
Microsoft.Windows.Component.Metadata ->
C:\.tools\.nuget\packages\microsoft.windows.winmdgenerator\0.67.4-preview\Sdk\Sdk.targets(101,5): error MSB4062: The "MetadataTasks.PrepSettingsForFunctionPointerFixups" task could not be loaded
from the assembly C:\.tools\.nuget\packages\microsoft.windows.winmdgenerator\0.67.4-preview\tools\net8.0\MetadataTasks.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Cultu
re=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all
its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [Q:\source\WinMdGenerationRepro\Metadata\Microsoft.Windows.Component.Met
adata\Microsoft.Windows.Component.Metadata.csproj]
Done Building Project "Q:\source\WinMdGenerationRepro\Metadata\Microsoft.Windows.Component.Metadata\Microsoft.Windows.Component.Metadata.csproj" (default targets) -- FAILED.

Build FAILED.

"Q:\source\WinMdGenerationRepro\Metadata\Microsoft.Windows.Component.Metadata\Microsoft.Windows.Component.Metadata.csproj" (default target) (1) ->
(PrepSettingsForFunctionPointerFixups target) ->
C:\.tools\.nuget\packages\microsoft.windows.winmdgenerator\0.67.4-preview\Sdk\Sdk.targets(101,5): error MSB4062: The "MetadataTasks.PrepSettingsForFunctionPointerFixups" task could not be loade
d from the assembly C:\.tools\.nuget\packages\microsoft.windows.winmdgenerator\0.67.4-preview\tools\net8.0\MetadataTasks.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Cul
ture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and al
l its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [Q:\source\WinMdGenerationRepro\Metadata\Microsoft.Windows.Component.M
etadata\Microsoft.Windows.Component.Metadata.csproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:02.40
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the basic .proj file using both dotnet build and msbuild. Inspect Sdk/Sdk.targets at line 101 and the tools/net8.0/MetadataTasks.dll task-loading path; done when the Microsoft.Windows.WinmdGenerator project builds successfully with msbuild as well as dotnet build.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.