Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dotnet-compile generates duplicate AssemblyInfoAttribute with ifdefs #6565

Closed
clairernovotny opened this issue Jul 2, 2016 · 1 comment
Closed

Comments

@clairernovotny
Copy link

Steps to reproduce

Create a new xproj/project.json project.

In the project's AssemblyInfo.cs, remove the existing AssemblyInfo attribute and use the code below:

This causes a failure

#if NETSTANDARD1_0 || WP8
[assembly: AssemblyVersion("3.0.0.0")]
#elif NETSTANDARD1_1 || WINDOWS8 || NET45 || NETCORE45
[assembly: AssemblyVersion("3.0.1000.0")]
#elif NETSTANDARD1_2 || WINDOWS81 || NET451 || NETCORE451 || WPA81
[assembly: AssemblyVersion("3.0.2000.0")]
#elif NETSTANDARD1_3 || NET46
[assembly: AssemblyVersion("3.0.3000.0")]
#elif NETSTANDARD1_4 || UAP10_0 || NETCORE50 || NET461
[assembly: AssemblyVersion("3.0.4000.0")]
#elif NETSTANDARD1_5 || NET462
[assembly: AssemblyVersion("3.0.5000.0")]
#elif NETSTANDARD1_6 || NETCOREAPP1_0 || NET463
[assembly: AssemblyVersion("3.0.6000.0")]
#endif

Adding an `#else` works despite the above logic covering all executable paths.

Try to compile. You get a duplicate attribute error. Looking at the obj directory, the tool has generated an AssemblyVersion attribute that it includes. 

Expected behavior

This should work. It shouldn't require an else if the defines are satisfied.

Actual behavior

Fails with duplicate attribute

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14379
OS Platform: Windows
RID: win10-x64

@clairernovotny clairernovotny changed the title dotnet-compile generates AssemblyInfoAttribute even if brought in via compile dotnet-compile generates duplicate AssemblyInfoAttribute with ifdefs Jul 4, 2016
@TheRealPiotrP
Copy link
Contributor

Take a look at this test and the next. You can use properties like < GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> to disable automatic generation. Less Magic!!

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants