Some projects can't be ported immediately after building all runtime
- 主要语言
- C#
- 星标
- 14
- 派生
- 21
- PR 合并指标
- 30 天内没有已合并 PR
描述
## Problem
After building the runtime repo project with:
```
build.cmd clr+libs -rc release
```
I was unable to port docs from Microsoft.Extensions.Hosting.WindowsServices due to an exception when opening the project: `Unresolved metadata reference removed from project`.
Output
```
$ PortToTripleSlash.exe \
-Docs $ENV:SOURCEREPOS\dotnet-api-docs\xml
-CsProj $ENV:SOURCEREPOS\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj
-IncludedAssemblies Microsoft.Extensions.Hosting.WindowsServices
-IncludedNamespaces Microsoft.Extensions.Hosting.WindowsServices
```
```
Verifying CLI arguments...
Specified Docs xml locations:
- C:\Users\calope\source\repos\dotnet-api-docs\xml
Included assemblies:
- Microsoft.Extensions.Hosting.WindowsServices
Included namespaces:
- Microsoft.Extensions.Hosting.WindowsServices
Querying for all Visual Studio instances...
Looking for the latest stable instance of Visual Studio, if there is one...
Selected instance:
- MSBuildPath: C:\Program Files\dotnet\sdk\7.0.200
- Version: 7.0.200
Attempting to register assembly loader...
Attempting to register Visual Studio instance
Successful Visual Studio load!
Looking for a resolved workspace that contains the project 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'...
Did not find an existing resolved project for path C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj. Creating a workspace for it...
Looking for a resolved project that contains the project 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'...
Did not find an existing resolved project for path 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'. Attempting to find the project in this workspace...
Found the project in this workspace. Attempting to get compilation...
Found the compilation for this project. Creating the resolved project...
Unhandled exception. System.Exception:
Project.OpenProjectAsync - C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj
Warning - Unresolved metadata reference removed from project: C:\Users\calope\source\repos\runtime\artifacts\bin\System.Diagnostics.DiagnosticSource\Debug\netstandard2.0\System.Diagnostics.DiagnosticSource.dll
at ApiDocsSync.PortToTripleSlash.MSBuildLoader.ThrowIfDiagnosticsFound(ResolvedWorkspace resolvedWorkspace, String origin, Boolean isMono) in C:\Users\calope\source\repos\api-docs-sync\src\PortToTripleSlash\src\libraries\MSBuildLoader.cs:line 175
at ApiDocsSync.PortToTripleSlash.MSBuildLoader.LoadProjectAsync(String projectPath, Boolean isMono, CancellationToken cancellationToken) in C:\Users\calope\source\repos\api-docs-sync\src\PortToTripleSlash\src\libraries\MSBuildLoader.cs:line 80
at ApiDocsSync.PortToTripleSlash.MSBuildLoader.LoadMainProjectAsync(String projectPath, Boolean isMono, CancellationToken cancellationToken) in C:\Users\calope\source\repos\api-docs-sync\src\PortToTripleSlash\src\libraries\MSBuildLoader.cs:line 63
at ApiDocsSync.PortToTripleSlash.PortToTripleSlash.Main(String[] args) in C:\Users\calope\source\repos\api-docs-sync\src\PortToTripleSlash\src\app\PortToTripleSlash.cs:line 19
at ApiDocsSync.PortToTripleSlash.PortToTripleSlash.(String[] args)
```
## Workaround
Go to the folder of that assembly and build it before porting:
```
$ cd .\src\libraries\Microsoft.Extensions.Hosting.WindowsServices
```
```
$ dotnet build
MSBuild version 17.6.0-preview-23174-01+e7de13307 for .NET
Determining projects to restore...
Restored C:\Users\calope\source\repos\runtime\src\libraries\Common\tests\TestUtilities\TestUtilities.csproj (in 1.11 sec).
Restored C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\tests\Microsoft.Extensions.Hosting.Windo
wsServices.Tests.csproj (in 1.09 sec).
78 of 80 projects are up-to-date for restore.
Microsoft.Interop.SourceGeneration -> C:\Users\calope\source\repos\runtime\artifacts\bin\Microsoft.Interop.SourceGeneration\Debug\netstandard2.0\
Microsoft.Interop.SourceGeneration.dll
Microsoft.Extensions.Primitives -> C:\Users\calope\source\repos\runtime\artifacts\bin\Microsoft.Extensions.Primitives\ref\Debug\net8.0\Microsoft.
Extensions.Primitives.dll
...
...
Build succeeded.
0 Warning(s)
0 Error(s)
```
Porting again succeeds:
Output
```
$ PortToTripleSlash.exe -Docs C:\Users\calope\source\repos\dotnet-api-docs\xml -CsProj C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj -IncludedAssemblies Microsoft.Extensions.Hosting.WindowsServices -IncludedNamespaces Microsoft.Extensions.Hosting.WindowsServices
Verifying CLI arguments...
Specified Docs xml locations:
- C:\Users\calope\source\repos\dotnet-api-docs\xml
Included assemblies:
- Microsoft.Extensions.Hosting.WindowsServices
Included namespaces:
- Microsoft.Extensions.Hosting.WindowsServices
Querying for all Visual Studio instances...
Looking for the latest stable instance of Visual Studio, if there is one...
Selected instance:
- MSBuildPath: C:\Program Files\dotnet\sdk\7.0.200
- Version: 7.0.200
Attempting to register assembly loader...
Attempting to register Visual Studio instance
Successful Visual Studio load!
Looking for a resolved workspace that contains the project 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'...
Did not find an existing resolved project for path C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj. Creating a workspace for it...
Looking for a resolved project that contains the project 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'...
Did not find an existing resolved project for path 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\Microsoft.Extensions.Hosting.WindowsServices.csproj'. Attempting to find the project in this workspace...
Found the project in this workspace. Attempting to get compilation...
Found the compilation for this project. Creating the resolved project...
Looking for Docs xml files...
Type 'T:Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers' added with 1 member(s) included: C:\Users\calope\source\repos\dotnet-api-docs\xml\Microsoft.Extensions.Hosting.WindowsServices\WindowsServiceHelpers.xml
Type 'T:Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceLifetime' added with 6 member(s) included: C:\Users\calope\source\repos\dotnet-api-docs\xml\Microsoft.Extensions.Hosting.WindowsServices\WindowsServiceLifetime.xml
Finished looking for Docs xml files.
Looking for symbol locations for all Docs types...
Symbol 'T:Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers' located in 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\WindowsServiceHelpers.cs'.
Adding tree 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\WindowsServiceHelpers.cs' for 'T:Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers'...
Looking for a resolved workspace that contains the project 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting\src\Microsoft.Extensions.Hosting.csproj'...
...
...
Now attempting to port all found symbols...
Porting comments for 'Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers'. Locations: 1...
Porting docs for tree 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\WindowsServiceHelpers.cs'...
Docs ported to 'Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceHelpers'.
Porting comments for 'Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceLifetime'. Locations: 1...
Porting docs for tree 'C:\Users\calope\source\repos\runtime\src\libraries\Microsoft.Extensions.Hosting.WindowsServices\src\WindowsServiceLifetime.cs'...
Docs ported to 'Microsoft.Extensions.Hosting.WindowsServices.WindowsServiceLifetime'.
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 src/PortToTripleSlash/src/libraries/MSBuildLoader.cs 开始,重点查看第 175 行的 ThrowIfDiagnosticsFound 和第 80 行的 LoadProjectAsync。使用 build.cmd clr+libs -rc release 和所示的 PortToTripleSlash 命令重现,然后验证在不手动重新构建项目的情况下,移植 Microsoft.Extensions.Hosting.WindowsServices 能够成功。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- documentation, tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100