3.0 preview8 sdk is unable to build some assemblies because the generated assmblyinfo.cs is throwing error CS0234 .
The exact build runs successfully when core 2.2 sdk.
3.0 preview8 sdk is unable to build some assemblies because the generated assmblyinfo.cs is throwing error. Some properties are copied from Directory.Build.props.
line:
_[assembly: Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute("secrets_file")]_
error:
_Error CS0234 The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)_
While building this library with 2.2 it runs successfully (not sure for preview versions between), preview8.0 fails to build.
@livarcocc or @nguerrera - any troubleshooting suggestions?
It is possible the namespace has moved from 2.2 to 3.0 on ASP.NET's side.
@mkArtakMSFT would you know?
Adding @Tratcher in case he has some contest here.
No, I don't see any changes here.
https://github.com/aspnet/Extensions/blob/e4ff9650f6c55390dce222b28b7a98d6ebc7350e/src/Configuration/Config.UserSecrets/src/UserSecretsIdAttribute.cs
https://github.com/aspnet/Extensions/blob/release/3.0/src/Configuration/Config.UserSecrets/src/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets
https://github.com/aspnet/websdk/blob/release/3.0.100-preview8/src/ProjectSystem/Targets/Microsoft.NET.Sdk.Web.ProjectSystem.targets
The implication is that it's missing the Microsoft.Extensions.* assembly references. Can you share the csproj file? Does it work if you change the library targetframework to netcoreapp3.0?
The SDK semi-blindly emits the attribute if UserSecretsId is set in the project, so if that is imported in a Directory.Build.props for a project that does not use the asp.net core shared framework or references the right packages, this will likely cause this issue.
cc @dsplaisted
This would be a breaking change in 3.0 SDK.
@BrunoDrljanovcan Can you share an example of a project that is failing to build with the updated sdk, or a binlog of the failing build?
This is super easy to isolate:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>foo</UserSecretsId>
</PropertyGroup>
</Project>
obj\Debug\netcoreapp3.0\testcons.AssemblyInfo.cs(14,22): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\demos\testcons\testcons.csproj]
Happens for any ~3.0~ project that does not provide a type for Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute.
Just that for the OP the UserSecretsId was set via a Directory.Build.props.
It's pretty much what @dasMulli wrote here. Although TargetFramework is netcoreapp2.2.
Relevant comment on PR when this was added: https://github.com/dotnet/sdk/pull/2774/files#r247013838
This will be fixed in 3.1.
It has also been added to the list of known issues for the .NET Core 3.0 SDK: https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-known-issues.md