You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build errors with multi-targeting Razor Class Library projects that include an MSBuild target depending on the CoreBuild target. (.NET SDK 9 Preview 7)
#43120
Closed
jsakamoto opened this issue
Aug 30, 2024
· 2 comments
I need to include the output files of my source generator to static web assets. So, I appended the following MSBuild target in the Blazor project files to follow @javiercn's advice.
...
<TargetName="..."DependsOnTargets="CoreCompile"BeforeTargets="AssignTargetPaths;ResolveStaticWebAssetsConfiguration">
<ItemGroup>
<!-- Include a source generator's output files here. -->
</ItemGroup>
</Target>
...
That worked fine for almost all kinds of Blazor projects. However, it failed with the following error messages when I tried to build a multi-targeting Razor Class Library project with the above MSBuild target, with the .NET SDK 9 Preview 7.
error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?)
error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
error CS0518: Predefined type 'System.String' is not defined or imported
...
Those errors were triggered when I just used the <TargetFrameworks> property in a Razor Class Library project file. It happened even when I specified only one target framework in that <TargetFrameworks> property, like below.
The build process succeeded when I rewrote the project file above to use the <TargetFramework> property. It also looks like there is no dependency on what the specified framework is. I've verified that this error happened on various of the "TargetFramworks" MSBuild property values, which are "net6.0", "net8.0", and "net9.0".
Again, the above MSBuild target worked fine on all kinds of projects, including multi-targeting projects, as long as they were Blazor Application projects, not Razor Class Library projects.
To Reproduce
Build the project I attached to this issue below with the .NET SDK 9 Preview 7. Then you will see the error messages I explained above.
jsakamoto
changed the title
Build errors with multi-targeting Razor Class Library projects that include an MSBuild target depending on the CoreBuild target.
Build errors with multi-targeting Razor Class Library projects that include an MSBuild target depending on the CoreBuild target. (.NET SDK 9 Preview 7)
Aug 30, 2024
Describe the bug
I need to include the output files of my source generator to static web assets. So, I appended the following MSBuild target in the Blazor project files to follow @javiercn's advice.
(See also: jsakamoto/Toolbelt.Blazor.I18nText#63)
That worked fine for almost all kinds of Blazor projects. However, it failed with the following error messages when I tried to build a multi-targeting Razor Class Library project with the above MSBuild target, with the .NET SDK 9 Preview 7.
Those errors were triggered when I just used the
<TargetFrameworks>
property in a Razor Class Library project file. It happened even when I specified only one target framework in that<TargetFrameworks>
property, like below.The build process succeeded when I rewrote the project file above to use the
<TargetFramework>
property. It also looks like there is no dependency on what the specified framework is. I've verified that this error happened on various of the "TargetFramworks" MSBuild property values, which are "net6.0", "net8.0", and "net9.0".Again, the above MSBuild target worked fine on all kinds of projects, including multi-targeting projects, as long as they were Blazor Application projects, not Razor Class Library projects.
To Reproduce
Build the project I attached to this issue below with the .NET SDK 9 Preview 7. Then you will see the error messages I explained above.
📦Net9SWALib.zip
Exceptions (if any)
The build process must be successful.
Further technical details
The output of the
dotnet --info
dotnet --info
The text was updated successfully, but these errors were encountered: