Skip to content
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

3.0 preview8 - Build failure with Directory.props and user secrets #3290

Closed
BrunoDrljanovcan opened this issue Sep 2, 2019 · 12 comments
Closed

Comments

@BrunoDrljanovcan
Copy link

BrunoDrljanovcan commented Sep 2, 2019

3.0 preview8 - Build failure with Directory.props and user secrets

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.

General

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.

@leecow
Copy link
Member

leecow commented Sep 5, 2019

@livarcocc or @nguerrera - any troubleshooting suggestions?

@livarcocc
Copy link

It is possible the namespace has moved from 2.2 to 3.0 on ASP.NET's side.

@mkArtakMSFT would you know?

@mkArtakMSFT
Copy link
Member

Adding @Tratcher in case he has some contest here.

@dasMulli
Copy link

dasMulli commented Sep 5, 2019

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.

See https://github.com/dotnet/sdk/blob/f16d813fa5671eea294073b76ef9019081034306/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets#L311-L337

@nguerrera
Copy link
Contributor

cc @dsplaisted

@nguerrera
Copy link
Contributor

This would be a breaking change in 3.0 SDK.

@dsplaisted
Copy link
Member

@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?

@dasMulli
Copy link

dasMulli commented Sep 12, 2019

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.

@BrunoDrljanovcan
Copy link
Author

It's pretty much what @dasMulli wrote here. Although TargetFramework is netcoreapp2.2.

@dsplaisted
Copy link
Member

Relevant comment on PR when this was added: https://github.com/dotnet/sdk/pull/2774/files#r247013838

@dsplaisted
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants