question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DoubleWritesAnalyzer produces false positives

See original GitHub issue

Scenario

  • C:\foo\FooApp\FooApp.sln includes the following projects.
    • C:\foo\FooApp\FooApp\FooApp.csproj
    • C:\foo\FooApp\FooApp.Tasks\FooApp.Tasks.csproj
  • The solution configuration specifies that both projects should build.
  • C:\foo\FooApp\FooApp\FooApp.csproj includes the following ProjectReference.
    <ProjectReference Include="..\FooApp.Tasks\FooApp.Tasks.csproj">
      <Project>{34c3ce97-aed1-4a7c-a105-9a41e6de5af5}</Project>
      <Name>FooApp.Tasks</Name>
    </ProjectReference>
  • The solution is built with a command line like the following. "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "C:\foo\FooApp\FooApp.sln" /t:build /v:diag /nologo /noconlog /logger:StructuredLogger,"C:\Users\FooUser\AppData\Local\MSBuildStructuredLogViewer\app-1.2.12\StructuredLogger.dll";"C:\Users\FooUser\AppData\Local\Temp\1\MSBuildStructuredLog-16128.buildlog"

Problem

The DoubleWrites report includes the following entry:

  • bin\Debug\netstandard2.0\FooApp.Tasks.dll
    • obj\Debug\netstandard2.0\FooApp.Tasks.dll
    • C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll

However, the reported destination file bin\Debug\netstandard2.0\FooApp.Tasks.dll is really 2 files:

  • C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
  • C:\foo\FooApp\FooApp\bin\Debug\netstandard2.0\FooApp.Tasks.dll

The DoubleWrites entry is therefore a false positive.

Log excerpts

Context of Excerpt 1

Project FooApp.sln (build target(s))
-> FooApp.csproj
--> Project FooApp.csproj (default targets)
---> Project FooApp.csproj (Build target(s))
----> Project FooApp.Tasks.csproj (default targets)
-----> Target Build
------> Target CoreBuild
-------> Target PrepareForRun
--------> Target CopyFilesToOutputDirectory
---------> Task Copy:

Excerpt 1

Copy
    Assembly = Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    Parameters
        SourceFiles = obj\Debug\netstandard2.0\FooApp.Tasks.dll
        DestinationFolder = bin\Debug\netstandard2.0\
        SkipUnchangedFiles = True
        OverwriteReadOnlyFiles = False
        UseHardlinksIfPossible = False
        UseSymboliclinksIfPossible = False
     Copying file from "obj\Debug\netstandard2.0\FooApp.Tasks.dll" to "bin\Debug\netstandard2.0\FooApp.Tasks.dll".

Context of Excerpt 2

Project FooApp.sln (build target(s))
-> FooApp.csproj
--> Project FooApp.csproj (default targets)
---> Project FooApp.csproj (Build target(s))
----> Target Build
-----> Target CoreBuild
------> Target PrepareForRun
-------> Target CopyFilesToOutputDirectory
--------> Target _CopyFilesMarkedCopyLocal
---------> Task Copy:

Excerpt 2

Copy
    Assembly = Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    Parameters
        SourceFiles
            C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
                BuildReference = true
                Configuration = Debug
                CopyLocal = true
                CopyUpToDateMarker = C:\foo\FooApp\FooApp.Tasks\obj\Debug\netstandard2.0\FooApp.Tasks.csproj.CopyComplete
                FullConfiguration = Debug|AnyCPU
                FusionName = FooApp.Tasks, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
                HasSingleTargetFramework = false
                ImageRuntime = v4.0.30319
                IsRidAgnostic = true
                MSBuildSourceProjectFile = C:\foo\FooApp\FooApp.Tasks\FooApp.Tasks.csproj
                MSBuildSourceTargetName = GetTargetFrameworks
                Name = FooApp.Tasks
                NearestTargetFramework = netstandard2.0
                OriginalItemSpec = C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
                OriginalProjectReferenceItemSpec = ..\FooApp.Tasks\FooApp.Tasks.csproj
                OutputItemType = 
                Platform = AnyCPU
                Project = {34c3ce97-aed1-4a7c-a105-9a41e6de5af5}
                ProjectReferenceOriginalItemSpec = ..\FooApp.Tasks\FooApp.Tasks.csproj
                ReferenceOutputAssembly = true
                ReferenceSourceTarget = ProjectReference
                ResolvedFrom = C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
                SetConfiguration = Configuration=Debug
                SetPlatform = Platform=AnyCPU
                SetTargetFramework = TargetFramework=netstandard2.0
                TargetFrameworkIdentifier = .NETStandard
                TargetFrameworks = netstandard2.0;net40
                TargetFrameworkVersion = 2.0
                TargetPlatformIdentifier = Windows
                TargetPlatformMoniker = Windows,Version=7.0
                Targets = 
                UndefineProperties = ;RuntimeIdentifier
                Version = 
        DestinationFiles
            bin\Debug\netstandard2.0\FooApp.Tasks.dll
                BuildReference = true
                Configuration = Debug
                CopyLocal = true
                CopyUpToDateMarker = C:\foo\FooApp\FooApp.Tasks\obj\Debug\netstandard2.0\FooApp.Tasks.csproj.CopyComplete
                FullConfiguration = Debug|AnyCPU
                FusionName = FooApp.Tasks, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
                HasSingleTargetFramework = false
                ImageRuntime = v4.0.30319
                IsRidAgnostic = true
                MSBuildSourceProjectFile = C:\foo\FooApp\FooApp.Tasks\FooApp.Tasks.csproj
                MSBuildSourceTargetName = GetTargetFrameworks
                Name = FooApp.Tasks
                NearestTargetFramework = netstandard2.0
                OriginalItemSpec = C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
                OriginalProjectReferenceItemSpec = ..\FooApp.Tasks\FooApp.Tasks.csproj
                OutputItemType = 
                Platform = AnyCPU
                Project = {34c3ce97-aed1-4a7c-a105-9a41e6de5af5}
                ProjectReferenceOriginalItemSpec = ..\FooApp.Tasks\FooApp.Tasks.csproj
                ReferenceOutputAssembly = true
                ReferenceSourceTarget = ProjectReference
                ResolvedFrom = C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll
                SetConfiguration = Configuration=Debug
                SetPlatform = Platform=AnyCPU
                SetTargetFramework = TargetFramework=netstandard2.0
                TargetFrameworkIdentifier = .NETStandard
                TargetFrameworks = netstandard2.0;net40
                TargetFrameworkVersion = 2.0
                TargetPlatformIdentifier = Windows
                TargetPlatformMoniker = Windows,Version=7.0
                Targets = 
                UndefineProperties = ;RuntimeIdentifier
                Version = 
        SkipUnchangedFiles = True
        OverwriteReadOnlyFiles = False
        UseHardlinksIfPossible = False
        UseSymboliclinksIfPossible = False
     Copying file from "C:\foo\FooApp\FooApp.Tasks\bin\Debug\netstandard2.0\FooApp.Tasks.dll" to "bin\Debug\netstandard2.0\FooApp.Tasks.dll".

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
KirillOsenkovcommented, Jul 11, 2018

Thanks for reporting. This is because the Copy task uses relative paths. We need to get MSBuild to switch to logging absolute paths there, then this won’t be an issue.

0reactions
KirillOsenkovcommented, May 29, 2019

I can confirm that the double-writes are gone and the Copy task now logs full paths:

image

Closing! Thanks for your attention to detail!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changes in MySQL 8.0.20 (2020-04-27, General Availability)
ORDER_INDEX : Causes MySQL to use the specified index or indexes for sorting rows. ... The error was a false-positive due to invalid...
Read more >
The way static analyzers fight against false positives, and ...
In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of...
Read more >
What Is A False Positive? Overview + Examples
Choosing the right code analyzer gives you better diagnostics and helps you to better identify false positives and negatives.
Read more >
CUS 1116 Midterm Review Flashcards
This can be useful if a program produces incorrect results and the programmer or tester is trying to detect where an incorrect value...
Read more >
False Positives in Static Code Analysis
A false positive arises when a static analysis tool falsely claims a static rule was breached. This article goes into great detail on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found