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

'dotnet build' produces no useful error messages #22332

Closed
livarcocc opened this issue Sep 25, 2017 · 17 comments
Closed

'dotnet build' produces no useful error messages #22332

livarcocc opened this issue Sep 25, 2017 · 17 comments

Comments

@livarcocc
Copy link

From @shinmai on August 30, 2017 10:19

Steps to reproduce

create a new project with dotnet new console
break project by making Program.cs unbuildable
execute dotnet build

Expected behavior

Useful error message referencing source file names and line numbers.

Actual behavior

error message is basically "it didn't work"

C:\_prj\a1>dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\2.0.0\Roslyn\Microsoft.CSharp.Core.targets(84,5): error MSB6006: "C:\Program Files\dotnet\sdk\2.0.0\Roslyn\RunCsc.cmd" exited with code 1. [C:\_prj\a1\a1.csproj]

Build FAILED.

C:\Program Files\dotnet\sdk\2.0.0\Roslyn\Microsoft.CSharp.Core.targets(84,5): error MSB6006: "C:\Program Files\dotnet\sdk\2.0.0\Roslyn\RunCsc.cmd" exited with code 1. [C:\_prj\a1\a1.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.46

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9

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

Microsoft .NET Core Shared Framework Host

Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Copied from original issue: dotnet/cli#7556

@livarcocc
Copy link
Author

From @omajid on August 30, 2017 13:20

break project by making Program.cs unbuildable

Can you elaborate on this? How exactly did you break it?

It looks like some specific cases lead to that in error. In other cases, I see fairly useful error messages. For example, if I remove one opening brace {, I see an error like:

Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(5,18): error CS1514: { expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]
Program.cs(5,18): error CS1513: } expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]
Program.cs(11,1): error CS1022: Type or namespace definition, or end-of-file expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]

Build FAILED.

Program.cs(5,18): error CS1514: { expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]
Program.cs(5,18): error CS1513: } expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]
Program.cs(11,1): error CS1022: Type or namespace definition, or end-of-file expected [/home/omajid/temp/HelloWorld/HelloWorld.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:01.40

@livarcocc
Copy link
Author

From @shinmai on August 30, 2017 15:9

No matter what kind of error I introduce, the only output I get is
C:\Program Files\dotnet\sdk\2.0.0\Roslyn\Microsoft.CSharp.Core.targets(84,5): error MSB6006: "C:\Program Files\dotnet\sdk\2.0.0\Roslyn\RunCsc.cmd" exited with code 1. [C:\_prj\a2\a2.csproj]

@livarcocc
Copy link
Author

From @svick on August 30, 2017 15:36

What is the output of dotnet build /v:n?

@livarcocc
Copy link
Author

From @nguerrera on August 31, 2017 5:46

@shinmai Can you also post the contents of Program.cs and a2.csproj?

@livarcocc
Copy link
Author

From @shinmai on August 31, 2017 8:33

What is the output of dotnet build /v:n?

Not much more helpful, but longer.

Can you also post the contents of Program.cs and a2.csproj?

Oh, sure.

Program.cs:

using System;

namespace a2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!") // ; commented out to introduce error
        }
    }
}

a2.csproj (a1 is identical, I was just testing with two projects side by side):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

</Project>

Both are untouched from what dotnet new console generates, aside from the intentional error to try and coax an useful error message from dotnet build.

I should note, error-free code builds and runs fine, but if there are build errors, I'm completely on my own in tracking them down, which is obviously something of a hassle in even rather trivial programs.

@livarcocc
Copy link
Author

From @dasMulli on August 31, 2017 9:26

Those errors won't log on /v:n but only on /v:diag AFAIK.

It does not repro on my machine though:

Program.cs(9,46): error CS1002: ; expected [C:\Users\martin.ullrich\Documents\a2\a2.csproj]

@livarcocc
Copy link
Author

From @nguerrera on August 31, 2017 12:57

Please share the output of dotnet build /v:diag

@livarcocc
Copy link
Author

From @wli3 on September 13, 2017 19:53

Hi @shinmai are you still seeing this problem?

@livarcocc
Copy link
Author

From @anavarro9731 on September 16, 2017 20:46

I have the same issue. Works on my dev machine but fails on VSTS Build.
C:\Program Files\dotnet\sdk\2.0.0\Roslyn\Microsoft.CSharp.Core.targets(84,5): error MSB6006: "C:\Program Files\dotnet\sdk\2.0.0\Roslyn\RunCsc.cmd" exited with code -2146232797. [D:\a\1\s\XXXXXXX.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:43.52

@livarcocc
Copy link
Author

From @nguerrera on September 18, 2017 19:52

Error code -2146232797 is 0x80131623 == COR_E_FAILFAST.

@anavarro9731 Are you able to bump the verbosity, e.g. dotnet build /v:diag in the VSTS build so that we can find the stack trace in order to get closer to the root cause.

@livarcocc
Copy link
Author

From @anavarro9731 on September 23, 2017 15:6

@nguerrera I have tracked down the problem, it is related to the scoping of variables in one class. In particular how variables declared at method-level scope are accessed by local functions within that method. Changing the structure of the code to pass the method-level variable to the local functions via an argument rather than having them access the outer scope directly solves the problem. I can send you the build output and both version of the file in question if you provide me a way to send them to you. It also appears this is only a problem on the very latest version of the compiler. We have confirmed on several machines that installing the latest visual studio update causes the problem to manifest.

@livarcocc
Copy link
Author

@jaredpar it feels like we should move this issue to roslyn.

@livarcocc
Copy link
Author

From @anavarro9731 on September 23, 2017 18:3

before we found the offending code we used the fix here:
https://developercommunity.visualstudio.com/content/problem/94629/error-msb6006-cscexe-exited-with-code-2146232797.html
which i suspect may be the same issue...

@livarcocc
Copy link
Author

From @svick on September 23, 2017 19:38

@anavarro9731 That description makes it sound like #19033. But if you have a repro, it might still make sense to open an issue on Roslyn, to make sure it's indeed the same issue.

@livarcocc
Copy link
Author

Moving this to Roslyn for now to see if it is indeed a duplicate. If this is something that needs to be addressed in the CLI, please re-activate.

@jcouv
Copy link
Member

jcouv commented Sep 30, 2017

@anavarro9731 From the thread above and your description ("how variables declared at method-level scope are accessed by local functions within that method"), I think this is a known issue which is fixed in 15.5. The first preview of 15.5 will be available in October.
The distinctive stacktrace is below.

If you have source code to repro, we will confirm this was indeed fixed.

FYI @agocke

 System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.RewriteLambdaOrLocalFunction(IBoundLambdaOrFunction node, ClosureKind& closureKind, NamedTypeSymbol& translatedLambdaContainer, LambdaFrame& containerAsFrame, BoundNode& lambdaScope, DebugId& topLevelMethodId, DebugId& lambdaId)
   at Microsoft.CodeAnalysis.CSharp.LambdaRewriter.VisitLocalFunctionStatement(BoundLocalFunctionStatement node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeRewriterWithStackGuard.Visit(BoundNode node)

@jcouv jcouv added the Feature - Local Functions Local Functions label Sep 30, 2017
@jcouv jcouv added this to the 15.5 milestone Sep 30, 2017
@jcouv
Copy link
Member

jcouv commented Oct 6, 2017

I'll go ahead and close (as far as I can tell, this compiler crash was fixed).
@anavarro9731, feel free to re-open if you still encounter the issue with 15.5 preview 1 (or later). Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants