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

Exec EchoOff="true" does not work #2826

Closed
ctaggart opened this issue Dec 27, 2017 · 3 comments
Closed

Exec EchoOff="true" does not work #2826

ctaggart opened this issue Dec 27, 2017 · 3 comments
Labels
Documentation Issues about docs, including errors and areas we should extend (this repo and learn.microsoft.com) triaged

Comments

@ctaggart
Copy link

Steps to reproduce

Either include a project sample, attach a zipped project, or provide IDE / CLI steps to create the project and repro the behaviour. Example of a project sample:

Project file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <Target Name="DebugEchoOff" BeforeTargets="Build">
    <Exec Command="git rev-parse HEAD" ConsoleToMsBuild="true" EchoOff="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="SourceLinkCommit" />
    </Exec>
    <Message Importance="high" Text="SourceLinkCommit: $(SourceLinkCommit)" />
  </Target>
</Project>

Directory contents:
https://github.com/ctaggart/sourcelink-test/tree/EchoOff/VS2017CSharpLibraryCore
image

Command line

dotnet build

Expected behavior

C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore [EchoOff +0 ~2 -0 !]> dotnet build
Microsoft (R) Build Engine version 15.5.179.9764 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\VS2017CSharpLibraryCore.csproj...
  Restore completed in 87.18 ms for C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\VS2017CSharpLibraryCore.csproj.
  VS2017CSharpLibraryCore -> C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\bin\Debug\net461\VS2017CSharpLibraryCore.dll
  SourceLinkCommit: 3a8feea438d3f097fbada82c37dc35206c9775fe

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.95

Actual behavior

C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore [EchoOff +0 ~2 -0 !]> dotnet build
Microsoft (R) Build Engine version 15.5.179.9764 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\VS2017CSharpLibraryCore.csproj...
  Restore completed in 87.18 ms for C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\VS2017CSharpLibraryCore.csproj.
  VS2017CSharpLibraryCore -> C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore\bin\Debug\net461\VS2017CSharpLibraryCore.dll
  3a8feea438d3f097fbada82c37dc35206c9775fe
  SourceLinkCommit: 3a8feea438d3f097fbada82c37dc35206c9775fe

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.95

Environment data

C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore [2.7 ≡ +1 ~1 -0 !]> dotnet --info
.NET Command Line Tools (2.1.2)

Product Information:
 Version:            2.1.2
 Commit SHA-1 hash:  5695315371

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

C:\Users\camer\cs\sourcelink-test\VS2017CSharpLibraryCore [2.7 ≡ +1 ~1 -0 !]> dotnet msbuild /version
Microsoft (R) Build Engine version 15.5.179.9764 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

15.5.179.9764
@rainersigwald
Copy link
Member

Thanks for filing this!

I had to look through the source to figure out what was going on, which is no good. I'm changing this bug to be "update the docs so it's possible to understand this without looking in the code".

What EchoOff="true" does is avoid logging the command: https://github.com/Microsoft/msbuild/blob/f2754cdbf8f50b99101a001c29f19211368e3009/src/Tasks/Exec.cs#L391-L395

That's the difference between (at /verbosity:normal):

       DebugEchoOff:
         git rev-parse HEAD
         603aaaf589669dd9bf7a457ce70d3506eb69fc8f
         SourceLinkCommit: 603aaaf589669dd9bf7a457ce70d3506eb69fc8f

and

       DebugEchoOff:
         603aaaf589669dd9bf7a457ce70d3506eb69fc8f
         SourceLinkCommit: 603aaaf589669dd9bf7a457ce70d3506eb69fc8f

The extra output you're seeing in the build isn't from echoing the command, but from Exec logging the standard output of the command. It does that because Exec sets its default StandardOutputImportance to High.

You can override that default by explicitly specifying StandardOutputImportance="Low" in the Exec invocation. Then only detailed-and-higher logging will print it. I tested this in your example project.

It's especially confusing because the command line is not logged at dotnet's default verbosity (which is minimal), so if you usually build using dotnet build it looks like EchoOff does nothing!

@rainersigwald rainersigwald added the Documentation Issues about docs, including errors and areas we should extend (this repo and learn.microsoft.com) label Jan 4, 2018
@rainersigwald
Copy link
Member

Please let us know if there's anything else we can do to further clarify this.

@ctaggart
Copy link
Author

ctaggart commented Jan 5, 2018

Thank you!

@ctaggart ctaggart closed this as completed Jan 5, 2018
Happypig375 added a commit to verybadcat/CSharpMath that referenced this issue Jun 11, 2020
Happypig375 added a commit to verybadcat/CSharpMath that referenced this issue Jun 11, 2020
* Update Directory.Build.props

* No limiting to master for now

* snupkgs

* SourceLink!

* Generate a package

* Yooooo

* dotnet/msbuild#2826

* Comment it

* Use preview language features

* Limit to master

* Revert unintentional change

* ReadMe: SourceLink for CI packages

* Fix grammar
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues about docs, including errors and areas we should extend (this repo and learn.microsoft.com) triaged
Projects
None yet
Development

No branches or pull requests

3 participants