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
Error CS9137 Occurred When Building a MAUI Project Targetting to Windows #9785
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsDescriptionConfiguration Binding Source Generator is introduced by .NET8.0, and it works well in my web projects. I attempt to use this generator in my MAUI Blazor App by modifying the .csproj file like:
It does function when targetting to net8.0-android, net8.0-ios, and net8.0-maccatalyst . However, a cs9137 error occurrs when set targetting to net8.0-windows10.0.19041.0. I followed the message and added Reproduction StepsAdd codes below in PropertyGroup:
Here is my test project Uploading TestMauiBlazor.zip…. Expected behaviorThe Configuration Binding Source Generator will generate codes, and the compiler will compile the codes successfully. Actual behaviorThe Configuration Binding Source Generator does generate codes. But the compiler throws a CS9137 error and messages " The 'interceptors' experimental feature is not enabled. Add Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
Tagging subscribers to 'arch-android': @steveisok, @akoeplinger Issue DetailsDescriptionConfiguration Binding Source Generator is introduced by .NET8.0, and it works well in my web projects. I attempt to use this generator in my MAUI Blazor App by modifying the .csproj file like:
It does function when targetting to net8.0-android, net8.0-ios, and net8.0-maccatalyst . However, a cs9137 error occurrs when set targetting to net8.0-windows10.0.19041.0. I followed the message and added Reproduction StepsAdd codes below in PropertyGroup:
Here is my test project TestMauiBlazor.zip. Expected behaviorThe Configuration Binding Source Generator will generate codes, and the compiler will compile the codes successfully. Actual behaviorThe Configuration Binding Source Generator does generate codes. But the compiler throws a CS9137 error and messages " The 'interceptors' experimental feature is not enabled. Add Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
@SloneWang looking at the doc, it says
Could you please try adding the |
This issue has been marked |
I tried to add
in PropertyGroup, but it didn't work and the error still occurred. |
CC @jaredpar @eiriktsarpalis @ericstj any thoughts? |
Looks to me like the failure is occurring in the msbuild/src/Tasks/Microsoft.CSharp.CurrentVersion.targets Lines 237 to 300 in 42383a8
To workaround this, I was able to do the following. Not sure if there's a better way. In the project file set: <CompilerResponseFile>$(CompilerResponseFile);WorkaroundXamlPreCompilePreviewFeatures.rsp</CompilerResponseFile> Include a file next to the project named
I think the bug here is that |
@ericstj nailed it. And a nice workaround! The full diff on that task invocation is now diff --git a/src/Tasks/Microsoft.CSharp.CurrentVersion.targets b/src/Tasks/Microsoft.CSharp.CurrentVersion.targets
index 772d1bbcf8e..f2ff137f100 100644
--- a/src/Tasks/Microsoft.CSharp.CurrentVersion.targets
+++ b/src/Tasks/Microsoft.CSharp.CurrentVersion.targets
@@ -244,21 +244,29 @@ Copyright (C) Microsoft Corporation. All rights reserved.
ApplicationConfiguration="$(AppConfigForCompiler)"
BaseAddress="$(BaseAddress)"
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
+ ChecksumAlgorithm="$(ChecksumAlgorithm)"
CodeAnalysisRuleSet="$(ResolvedCodeAnalysisRuleSet)"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(DefineConstants)"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
+ DisableSdkPath="$(DisableSdkPath)"
DocumentationFile="@(DocFileItem)"
+ EmbedAllSources="$(EmbedAllSources)"
+ EmbeddedFiles="@(EmbeddedFiles)"
EmitDebugInformation="$(DebugSymbols)"
EnvironmentVariables="$(CscEnvironment)"
ErrorEndLocation="$(ErrorEndLocation)"
ErrorLog="$(ErrorLog)"
ErrorReport="$(ErrorReport)"
+ Features="$(Features)"
+ InterceptorsPreviewNamespaces="$(InterceptorsPreviewNamespaces)"
FileAlignment="$(FileAlignment)"
+ GeneratedFilesOutputPath="$(CompilerGeneratedFilesOutputPath)"
GenerateFullPaths="$(GenerateFullPaths)"
HighEntropyVA="$(HighEntropyVA)"
+ Instrument="$(Instrument)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
@@ -271,19 +279,30 @@ Copyright (C) Microsoft Corporation. All rights reserved.
NoWin32Manifest="$(NoWin32Manifest)"
Nullable="$(Nullable)"
Optimize="$(Optimize)"
- OutputAssembly="@(XamlIntermediateAssembly)"
+ Deterministic="$(Deterministic)"
+ PublicSign="$(PublicSign)"
+ OutputAssembly="@(IntermediateAssembly)"
+ OutputRefAssembly="@(IntermediateRefAssembly)"
PdbFile="$(PdbFile)"
Platform="$(PlatformTarget)"
Prefer32Bit="$(Prefer32Bit)"
PreferredUILang="$(PreferredUILang)"
- References="@(ReferencePath)"
+ ProjectName="$(MSBuildProjectName)"
+ ProvideCommandLineArgs="$(ProvideCommandLineArgs)"
+ References="@(ReferencePathWithRefAssemblies)"
+ RefOnly="$(ProduceOnlyReferenceAssembly)"
ReportAnalyzer="$(ReportAnalyzer)"
+ ReportIVTs="$(ReportIVTs)"
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
ResponseFiles="$(CompilerResponseFile)"
- SkipAnalyzers="true"
+ RuntimeMetadataVersion="$(RuntimeMetadataVersion)"
+ SharedCompilationId="$(SharedCompilationId)"
+ SkipAnalyzers="$(_SkipAnalyzers)"
+ SkipCompilerExecution="$(SkipCompilerExecution)"
Sources="@(Compile)"
SubsystemVersion="$(SubsystemVersion)"
TargetType="$(OutputType)"
+ TargetFramework="$(TargetFramework)"
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
@@ -297,6 +316,8 @@ Copyright (C) Microsoft Corporation. All rights reserved.
Win32Icon="$(ApplicationIcon)"
Win32Manifest="$(Win32Manifest)"
Win32Resource="$(Win32Resource)"
+ PathMap="$(PathMap)"
+ SourceLink="$(SourceLink)"
/>
<!-- Only Applicable to the regular CoreCompile: Some of those diffs are intentional ( @jaredpar heads up I'm going to send a PR to sync these two targets again and will need compiler team review please. |
Description
Configuration Binding Source Generator is introduced by .NET8.0, and it works well in my web projects. I attempt to use this generator in my MAUI Blazor App by modifying the .csproj file like:
It does function when targetting to net8.0-android, net8.0-ios, and net8.0-maccatalyst . However, a cs9137 error occurrs when set targetting to net8.0-windows10.0.19041.0. I followed the message and added
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces>
to project file, that error still occurrs.Reproduction Steps
Add codes below in PropertyGroup:
Here is my test project TestMauiBlazor.zip.
Expected behavior
The Configuration Binding Source Generator will generate codes, and the compiler will compile the codes successfully.
Actual behavior
The Configuration Binding Source Generator does generate codes. But the compiler throws a CS9137 error and messages " The 'interceptors' experimental feature is not enabled. Add
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces>
to your project. "Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: