Description
If install the Microsoft.AspNetCore.Components.WebView.Wpf NuGet package and use functions from Microsoft.Extensions.Options.ConfigurationExtensions, SelfContained publish in Visual Studio publish page will fail, but it works fine when using the command line dotnet publish -c Release -r win-x64 --self-contained true. If the “obj” folder is not deleted after running the command, the page will also publish successfully.
Reproduction Steps
- Create a WPF application ( .net9 or 10 ) , install the
Microsoft.AspNetCore.Components.WebView.Wpf NuGet package, and change the SDK to “Microsoft.NET.Sdk.Razor” to ensure successful compilation.
- If the webView nuget package just installed is version earlier than 10.0, install
Microsoft.Extensions.Options.ConfigurationExtensions as well; otherwise, the package already includes this.
- Call the function
public static IServiceCollection Configure<TOptions>(this IServiceCollection services, IConfiguration config), for example:
var serviceCollection = new ServiceCollection();
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true).Build();
serviceCollection.Configure<TestOption>(configuration);
public class TestOption { }
- Right-click the project, select publish, choose folder and SelfContained release x64 , click “Publish,” and an error occurs.
Expected behavior
The button on the publish page should function normally, just like the output of a command-line execution.
Actual behavior
A window pops up indicating a publishing error, but no specific reason is shown.
Regression?
No response
Known Workarounds
Add the following property to PropertyGroup like:
<PropertyGroup>
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsNamespaces>
</PropertyGroup>
Or using the command line.
Impact
All packages that directly or indirectly reference Microsoft.Extensions.Options.ConfigurationExtensions, such as Microsoft.Extensions.Hosting
Configuration
No response
Other information
No response
Description
If install the
Microsoft.AspNetCore.Components.WebView.WpfNuGet package and use functions fromMicrosoft.Extensions.Options.ConfigurationExtensions, SelfContained publish in Visual Studio publish page will fail, but it works fine when using the command linedotnet publish -c Release -r win-x64 --self-contained true. If the “obj” folder is not deleted after running the command, the page will also publish successfully.Reproduction Steps
Microsoft.AspNetCore.Components.WebView.WpfNuGet package, and change the SDK to “Microsoft.NET.Sdk.Razor” to ensure successful compilation.Microsoft.Extensions.Options.ConfigurationExtensionsas well; otherwise, the package already includes this.public static IServiceCollection Configure<TOptions>(this IServiceCollection services, IConfiguration config), for example:Expected behavior
The button on the publish page should function normally, just like the output of a command-line execution.
Actual behavior
A window pops up indicating a publishing error, but no specific reason is shown.
Regression?
No response
Known Workarounds
Add the following property to PropertyGroup like:
Or using the command line.
Impact
All packages that directly or indirectly reference
Microsoft.Extensions.Options.ConfigurationExtensions, such asMicrosoft.Extensions.HostingConfiguration
No response
Other information
No response