Skip to content

SDK defined properties overwrites WarningsAsErrors on solution level #3613

Closed

Description

@lg2de

The following statement is intended to define WarningsAsErrors for "NU1605" if not defined.

<WarningsAsErrors Condition=" '$(WarningsAsErrors)' == '' ">NU1605</WarningsAsErrors>

But defining <WarningsAsErrors /> at solution level (Directory.Build.props) may cause unexpected overwrite, e.g. in server (TFS) build:

2019-09-09T13:32:15.6813986Z                    Property reassignment: $(WarningsAsErrors)="NU1605" (previous value: "") at C:\build\_work\_tool\dncs\3.0.100-preview6-012264\x64\sdk\3.0.100-preview6-012264\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.CSharp.props (19,5)

Instead of getting "all warnings as errors" only NU1605 will be trait as error.

Activity

  1. lg2de commented on Sep 9, 2019

    @lg2de
    ContributorAuthor

    #1329 introduced this problem assuming that only an existing list of warnings is used.
    It is not working for "all warnings as error".

    The only work-around I found so far is: Specify <WarningsAsErrors /> in each project explicitly. But I would like to ensure enabling it in ALL projects.

  2. dsplaisted commented on Sep 13, 2019

    @dsplaisted
    Member

    @lg2de Can you put <WarningsAsErrors /> in the Directory.Build.targets file instead of the .props? Then it would set it after the default values from the .props.

    I also think it would make sense to change the relevant line in the props to this::

    <WarningsAsErrors>$(WarningsAsErrors);NU1605</WarningsAsErrors> 
  3. added a commit that references this issue on Sep 14, 2019
    8dfe0c2
  4. lg2de commented on Sep 14, 2019

    @lg2de
    ContributorAuthor

    Hey @dsplaisted. That's exactly what I thought. I created PR #3645 for it right away.

  5. added a commit that references this issue on Apr 29, 2020
    fd4c882
  6. added a commit that references this issue on Apr 30, 2020
    bc5c514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions