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

Transitive package references not followed #1036

Closed
wjk opened this issue Dec 23, 2016 · 3 comments
Closed

Transitive package references not followed #1036

wjk opened this issue Dec 23, 2016 · 3 comments

Comments

@wjk
Copy link
Contributor

wjk commented Dec 23, 2016

Please forgive me if this is a duplicate of something, or is filed in the wrong place; I have read several issues regarding reference handling errors and was not certain which most closely matches my symptoms.

Here is what I did to trigger this bug:

  1. Create a Visual Studio solution.
  2. In a subfolder, run dotnet new, then dotnet restore. I have modified the default csproj format slightly, to fit with the requirements and quirks of my larger project. In case this affects how it is parsed by Visual Studio, I have pasted the entire csproj file from my end below.
  3. Add the generated csproj to the solution. Open the Program.cs file within the project.
  4. Notice how the call to Console.WriteLine() in the example hello-world C# file does not parse properly. It tells me that "The name 'Console' does not exist in the current context." I am (supposedly) transitively referencing System.Console.dll through Microsoft.NETCore.App. However, this doesn't actually seem to be the case. Building using dotnet build at the command line also fails with the same error.

It is my understanding that referencing Microsoft.NETCore.App should also reference the appropriate DLLs from all the packages visible on the NuGet gallery. Unfortunately, this doesn't seem to be the case. If I add a <PackageReference> tag pointing to System.Console directly, then the issue goes away. Unfortunately, when I try that I run afoul of the problem described in my comment on #785. While transitive project references are not currently implemented (cf #199), this behavior concerning transitive package references seems to be caused by a different issue.


Here is the contents of the csproj file (slightly commented for readability):

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <AssemblyTitle>Windows Kernel Object Viewer</AssemblyTitle>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161026-2</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>

    <!-- Removing this line causes the error described above. -->
    <PackageReference Include="System.Console" Version="4.3.0" />

    <!-- These are references to other projects inside my solution. -->
    <ProjectReference Include="../../../Win32UI/src/Win32UI.Core/Win32UI.Core.csproj" />
    <ProjectReference Include="../../../Win32UI/src/Win32UI.MessageBox/Win32UI.MessageBox.csproj" />
    <ProjectReference Include="../../../Win32UI/src/Win32UI.TaskDialogs/Win32UI.TaskDialogs.csproj" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Strings.resx">
      <Generator />
    </EmbeddedResource>
  </ItemGroup>

  <!-- This file itself imports Microsoft.CSharp.targets. -->
  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))/dir.targets" />
</Project>
@davidfowl
Copy link
Member

I can't reproduce this with a file new project in VS 2017 RC2

@wjk
Copy link
Contributor Author

wjk commented Dec 23, 2016

@davidfowl Sorry I didn't get back to you earlier. I just created a brand-new project (dotnet new, unmodified), restored it, and it won't build. It complains that the Console type is not found, just as above. Creating the project using Visual Studio has the same issue, plus some complaints from MSBuild. (I will file an issue on dotnet/sdk about those.) Here is my dotnet --info output:

.NET Command Line Tools (1.0.0-preview4-004233)

Product Information:
 Version:            1.0.0-preview4-004233
 Commit SHA-1 hash:  8cec61c6f7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview4-004233

I will try updating my version of the CLI and get back to you if anything changes.

@srivatsn
Copy link
Contributor

Closing this issue since the original transitive refs issue doesn't repro anymore.

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

No branches or pull requests

3 participants