-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace file destination instructions for OpenAPI build-time documentation so projects can build correctly #34509
Conversation
@sander1095 What operating system did you observe these issues on? When this doc was written we observed that |
Hi @captainsafia ! I'm running on Windows 11. You're correct, when running on Ubuntu (via WSL), However, this means the docs should be updated:
This PR does the latter. I do not have a mac available to test this on. I believe we should advocate for a single solution that works for all OS's, as teams can use multiple OS's :). I remember you having a mac? If this works on your machine, would you consider accepting this approach? If you'd like me to take a different path, let me know! |
Just a side note with a verification point: It compiled, no build error for that particular setup using either: |
Does this mean this can get merged @captainsafia ? |
@captainsafia, I think it is not clear where you would like us to go from here with this PR. Thoughts? |
@sander1095 what OS and version? What .NET version? This happened on preview versions but was fixed in .NET 9 GA. |
WSL (Ubuntu 22.04)
Windows 11 Pro (10.0.22631 Build 22631, 23H2)
Building with ./The final csproj<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OpenApiDocumentsDirectory>./</OpenApiDocumentsDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> Windows 11 Pro ❌dotnet new webapi -f net9.0
dotnet add package Microsoft.Extensions.ApiDescription.Server -v 9.0.1 # Install the latest version from nuget
# Add <OpenApiDocumentsDirectory>./</OpenApiDocumentsDirectory> to the csproj
dotnet build
# ERROR
PS C:\projects\Personal\temp6> dotnet build
Restore complete (0,3s)
temp6 failed with 2 error(s) (2,1s) → bin\Debug\net9.0\temp6.dll
C:\Users\stenb\.nuget\packages\microsoft.extensions.apidescription.server\9.0.1\build\Microsoft.Extensions.ApiDescription.Server.targets(68,5): error : Missing required option '--project'.
C:\Users\stenb\.nuget\packages\microsoft.extensions.apidescription.server\9.0.1\build\Microsoft.Extensions.ApiDescription.Server.targets(68,5): error MSB3073: The command "dotnet "C:\Users\stenb\.nuget\packages\microsoft.extensions.apidescription.server\9.0.1\build\../tools/dotnet-getdocument.dll" --assembly "C:\projects\Personal\temp6\bin\Debug\net9.0\temp6.dll" --file-list "obj\temp6.OpenApiFiles.cache" --framework ".NETCoreApp,Version=v9.0" --output "C:\projects\Personal\temp6\" --project "temp6" --assets-file "C:\projects\Personal\temp6\obj\project.assets.json" --platform "AnyCPU" " exited with code 1.
Build failed with 2 error(s) in 2,6s WSL (Ubuntu 22.04) ✅dotnet new webapi -f net9.0
dotnet add package Microsoft.Extensions.ApiDescription.Server -v 9.0.1 # Install the latest version from nuget
# Add <OpenApiDocumentsDirectory>./</OpenApiDocumentsDirectory> to the csproj
dotnet build
# SUCCESS
sander@PC-Sander:~/projects/temp$ dotnet build
Restore complete (0.5s)
temp succeeded (2.6s) → bin/Debug/net9.0/temp.dll
Build succeeded in 3.4s Building with .The final csproj<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> Windows 11 Pro ✅dotnet new webapi -f net9.0
dotnet add package Microsoft.Extensions.ApiDescription.Server -v 9.0.1 # Install the latest version from nuget
# Add <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory> to the csproj
dotnet build
# SUCCESS
PS C:\projects\Personal\temp6> dotnet build
Restore complete (0,3s)
temp6 succeeded (0,7s) → bin\Debug\net9.0\temp6.dll
Build succeeded in 1,2s WSL (Ubuntu 22.04) ✅dotnet new webapi -f net9.0
dotnet add package Microsoft.Extensions.ApiDescription.Server -v 9.0.1 # Install the latest version from nuget
# Add <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory> to the csproj
dotnet build
# SUCCESS
sander@PC-Sander:~/projects/temp$ dotnet build
Restore complete (0.5s)
temp succeeded (2.6s) → bin/Debug/net9.0/temp.dll
Build succeeded in 3.4s I hope this gives you all the info you need! As far as I see it, this issue persists in .NET 9 GA but is fixed on both Windows and Ubuntu when using |
That's not what @sander1095 and I found out. Easy to repo the failure Looks like it never got fixed from when I reported it. Maybe I forgot to update the doc. |
@sander1095 thanks for reporting and fixing this. Sorry it took so long to accept your PR. Keep them coming and I promise next time more prompt attention. |
Fixes #34508
Internal previews