Hi all,
Having an issue during what I think should be a simple scenario -- a domain class lib and a console app that references it, where the domain project does nothing and the console app is the standard Hello World.
NOTE: I previously had .NET Core 1.x on my system, but I uninstalled it as part of trying to troubleshoot this issue.
Code sample that repros the issue on my system can be found at https://github.com/SeanKilleen/corefx-23906-issuerepro.
dotnet new solution -o PingPong
. This creates new empty solution in the PingPong directoryPingPong
directory.dotnet new console -o PingPong.Console
which creates a folder and the console appdotnet new console -o PingPong.Domain
which creates a folder and the class lib projectdotnet sln PingPong.sln add PingPong.Console\PingPong.Console.csproj
and dotnet sln PingPong.sln add PingPong.Domain\PingPong.Domain.csproj
dotnet add PingPong.Console\PingPong.Console.csproj reference PingPong.Domain\PingPong.Domain.csproj
dotnet restore PingPong.sln
to update the packagesdotnet build PingPong.sln
to build the solutionHere I hit my first snag, an error: Program.cs(9,13): error CS0234: The type or namespace name 'WriteLine' does not exist in the namespace 'PingPong.Console' (are you missing an assembly reference?)
To show the steps I'm taking in case something is crucially wrong:
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\Users\Sean\Desktop\temp\issuerepro> dotnet new solution -o PingPong
The template "Solution File" was created successfully.
PS C:\Users\Sean\Desktop\temp\issuerepro> cd .\PingPong\
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet new console -o PingPong.Console
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on PingPong.Console\PingPong.Console.csproj...
Restoring packages for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj...
Generating MSBuild file C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\obj\PingPong.Console.csproj.nuget.g.props.
Generating MSBuild file C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\obj\PingPong.Console.csproj.nuget.g.targets.
Restore completed in 260.07 ms for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj.
Restore succeeded.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet new console -o PingPong.Domain
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on PingPong.Domain\PingPong.Domain.csproj...
Restoring packages for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\PingPong.Domain.csproj...
Generating MSBuild file C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\obj\PingPong.Domain.csproj.nuget.g.props.
Generating MSBuild file C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\obj\PingPong.Domain.csproj.nuget.g.targets.
Restore completed in 200.18 ms for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\PingPong.Domain.csproj.
Restore succeeded.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet sln PingPong.sln add PingPong.Console\PingPong.Console.csproj
Project `PingPong.Console\PingPong.Console.csproj` added to the solution.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet sln PingPong.sln add PingPong.Domain\PingPong.Domain.csproj
Project `PingPong.Domain\PingPong.Domain.csproj` added to the solution.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet add PingPong.Console\PingPong.Console.csproj reference PingPong.Domain\PingPong.Domain.csproj
Reference `..\PingPong.Domain\PingPong.Domain.csproj` added to the project.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet restore PingPong.sln
Restoring packages for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj...
Restore completed in 16.47 ms for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\PingPong.Domain.csproj.
Restore completed in 170.16 ms for C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj.
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong> dotnet build PingPong.sln
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
PingPong.Domain -> C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Domain\bin\Debug\netcoreapp2.0\PingPong.Domain.dll
Program.cs(9,13): error CS0234: The type or namespace name 'WriteLine' does not exist in the namespace 'PingPong.Console' (are you missing an assembly r
eference?) [C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj]
Build FAILED.
Program.cs(9,13): error CS0234: The type or namespace name 'WriteLine' does not exist in the namespace 'PingPong.Console' (are you missing an assembly r
eference?) [C:\Users\Sean\Desktop\temp\issuerepro\PingPong\PingPong.Console\PingPong.Console.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:04.51
PS C:\Users\Sean\Desktop\temp\issuerepro\PingPong>
Can't see repo, so guess:
Namespace PingPong.Console
is taking precedence over System
so it can't find the class Console
?
Gahhhhh that was it! Simple fix. Always nice when the hour I lost on new tooling is actually something dumb and obvious. 馃槅 Thanks for the pointer!
Argh, glad this is here! Ran into the same issue.
Face plant! Ran into same issue.
I have now done this twice and found this issue twice... 馃槅
I'm new to this stuff but if I create a Console app in Visual studio i get:
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Which compiles happily. So what's the difference when using Command prompt?
@Elracorey if you are having an issue still, please open a new issue with repro steps.
Most helpful comment
Can't see repo, so guess:
Namespace
PingPong.Console
is taking precedence overSystem
so it can't find the classConsole
?