Skip to content

Update BuildFromSource.md to explain CS0006 errors #10465

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

Merged
merged 2 commits into from
May 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions docs/BuildFromSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Building ASP.NET Core on Windows requires:
* Oracle's JDK <https://www.oracle.com/technetwork/java/javase/downloads/index.html>
* To install a version of the JDK that will only be used by this repo, run [eng/scripts/InstallJdk.ps1](/eng/scripts/InstallJdk.ps1)
```ps1
PS> ./eng/scripts/InstalLJdk.ps1
PS> ./eng/scripts/InstallJdk.ps1
```

### macOS/Linux
Expand Down Expand Up @@ -81,21 +81,24 @@ Instead, we have many .sln files which include a sub-set of projects. These prin

> :bulb: Pro tip: `dotnet new sln` and `dotnet sln` are one of the easiest ways to create and modify solutions.

### Known issue: NU1105
### Common error: CS0006
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can external contributors who are not themselves adding a new project hit this? That is, doesn't CodeCheck.ps1 prevent seeing this error in 'master'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. CodeCheck.ps1 only checks that each .csproj referenced from a .sln exists. It doesn't check that the entire project reference graph has been added to the solution.


Opening solution files may produce an error code NU1105 with a message such
Opening solution files and building may produce an error code CS0006 with a message such

> Unable to find project information for 'C:\src\AspNetCore\src\Hosting\Abstractions\src\Microsoft.AspNetCore.Hosting.Abstractions.csproj'. Inside Visual Studio, this may be because the project is unloaded or not part of current solution. Otherwise the project file may be invalid or missing targets required for restore.
> Error CS0006 Metadata file 'C:\src\aspnet\AspNetCore\artifacts\bin\Microsoft.AspNetCore.Metadata\Debug\netstandard2.0\Microsoft.AspNetCore.Metadata.dll' could not be found

This is a known issue in NuGet (<https://github.com/NuGet/Home/issues/5820>) and we are working with them for a solution. See also <https://github.com/aspnet/AspNetCore/issues/4183> to track progress on this.
The cause of this problem is that the solution you are using does not include the project that produces this .dll. This most often occurs after we have added new projects to the repo, but failed to update our .sln files to include the new project. In some cases, it is sometimes the intended behavior of the .sln which has been crafted to only include a subset of projects.

**The workaround** for now is to add all projects to the solution. You can either do this one by one using `dotnet sln`

dotnet sln add C:\src\AspNetCore\src\Hosting\Abstractions\src\Microsoft.AspNetCore.Hosting.Abstractions.csproj

Or you can use this script to automatically traverse the project reference graph, which then invokes `dotnet sln` for you: [eng/scripts/AddAllProjectRefsToSolution.ps1](/eng/scripts/AddAllProjectRefsToSolution.ps1).

./eng/scripts/AddAllProjectRefsToSolution.ps1 -WorkingDir src/Mvc/
**You can fix this in one of two ways**
1. Build the project on command line. In most cases, running `build.cmd` on command line solve this problem.
2. Update the solution to include the missing project. You can either do this one by one using `dotnet sln`
```
dotnet sln add C:\src\AspNetCore\src\Hosting\Abstractions\src\Microsoft.AspNetCore.Hosting.Abstractions.csproj
```
Or you can use this script to automatically traverse the project reference graph, which then invokes `dotnet sln` for you: [eng/scripts/AddAllProjectRefsToSolution.ps1](/eng/scripts/AddAllProjectRefsToSolution.ps1).
```
./eng/scripts/AddAllProjectRefsToSolution.ps1 -WorkingDir src/Mvc/
```

## Building with Visual Studio Code

Expand Down