Project-system: Explicit Conditional Constants added to Project file Duplicate Implicit ones

Created on 17 Aug 2017  路  13Comments  路  Source: dotnet/project-system

Based on VSFeedback | 457114

When a custom conditional compilation constant is added to a project, it inserts an explicit constant for the framework, which duplicates the implicit ones.

Repro Steps

  • Create new .NET Core Console App
  • Open Properties | Build and add a constant to Conditional Compilation symbols:
    image
  • Close and Reopen Property pages

Expected
Constants remain the same

Actual
NETCOREAPP1_1 is repeated twice:
image

Notes and Workaround
An explicit constant is added to the project file which duplicates the implicit constant:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DefineConstants>TRACE;DEBUG;NETCOREAPP1_1;SOMECONSTANT</DefineConstants>
  </PropertyGroup>

Removing that constant eliminates the duplicate in the property pages, and it is likely not needed because an implicit constant is defined at Microsoft.NET.Sdk.CSharp.targets#L34

This is likely the root cause of #1440 which can be duped against this.

Bug Feature-RuleProperties

Most helpful comment

Will be fixed in v15.6.7?

All 13 comments

How is removing the constant a fix for this?

I have my own build symbols I want to add and every time I resave the project it adds NET461 etc again. What is the work around for this?

Totally agree with @rolandh. See my comments on that in context of issue https://github.com/dotnet/project-system/issues/2733#issuecomment-352244818
When the hell is that fixed? I work with latest stable VS2017 15.5.2 from 14th December and it is still not fixed.

I stopped using netcore literally because of how annoying this was.

The whole. New csproj format seems flaky and unfinished. I do not feel that netcore is production ready.

@rolandh Above is not suggesting removing the constant as a fix for this, it's providing a workaround for those affected by it.

Understood how frustrating this bug is - we've been prioritizing bugs that affect the inner loop (things developers do over and over again) and with no workaround, over issues are affect outer loop (things developers only do a few times a day or less) with a workaround.

Still happening in v15.6.4

It seems quite old now and is yet not fixed till today

Will be fixed in v15.6.7?

Still failing in v15.6.7. NetStandard project Scenarios failing:

Scenario 1
Set focus to "conditional compilation symbols" textbox and add semicolon and press Intro or TAB or Alt+Tab: textbox self modified with "NETSTANDARD2_0;NETSTANDARD2_0" text.

Scenario 2
Set focus to "conditional compilation symbols" textbox and add semicolon and other symbol and press Intro or TAB: textbox self modified with "NETSTANDARD2_0;mine;NETSTANDARD2_0". Not failing when press Alt+Tab combined keys.

Cheers

This will be fixed in 15.8 Preview 3.

Seems solved in 15.8.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings