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

reference local assembly in dotnet core 2.0 preview 2 #1417

Closed
patricksuo opened this issue Jul 17, 2017 · 4 comments
Closed

reference local assembly in dotnet core 2.0 preview 2 #1417

patricksuo opened this issue Jul 17, 2017 · 4 comments

Comments

@patricksuo
Copy link

patricksuo commented Jul 17, 2017

#120 said: dotnet core 2.0 SUPPORT local DLL.
But I encounter some problems.

platform: 16.6.0 Darwin Kernel Version 16.6.0 or macOS Sierra 10.12.5

dotnet info

.NET Command Line Tools (2.0.0-preview2-006391)

Product Information:
 Version:            2.0.0-preview2-006391
 Commit SHA-1 hash:  ef5d4b47c3

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.0-preview2-006391/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview2-25407-01
  Build    : 40c565230930ead58a50719c0ec799df77bddee9

reproduce:

  1. dotnet new console -n LocalDll
  2. cd LocalDll
  3. mkdir Dll
  4. cp ~/MsgPack.dll Dll/ (see attachment, need rename MsgPack.zip to MsgPack.dll)
  5. using MsgPack in Program.cs
using System;
using MsgPack;

namespace LocalDll
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
  1. reference MsgPack in csproj file
<Project Sdk="Microsoft.NET.Sdk">

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

	<ItemGroup>
		<Reference Include="MsgPack">
			<HintPath>Dll\MsgPack.dll</HintPath>
		</Reference>
	</ItemGroup>

</Project>
  1. dotnet build
Microsoft (R) Build Engine version 15.3.378.6360 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

/usr/local/share/dotnet/sdk/2.0.0-preview2-006391/Microsoft.Common.CurrentVersion.targets(1978,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Invalid PE signature. [/Users/xxx/project/LocalDll/LocalDll.csproj]
Program.cs(2,7): error CS0246: The type or namespace name 'MsgPack' could not be found (are you missing a using directive or an assembly reference?) [/Users/xxx/project/LocalDll/LocalDll.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/2.0.0-preview2-006391/Microsoft.Common.CurrentVersion.targets(1978,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Invalid PE signature. [/Users/xxx/project/LocalDll/LocalDll.csproj]
Program.cs(2,7): error CS0246: The type or namespace name 'MsgPack' could not be found (are you missing a using directive or an assembly reference?) [/Users/xxx/project/LocalDll/LocalDll.csproj]
    1 Warning(s)
    1 Error(s)

Also, please set COREHOST_TRACE=1, run your app, and attach the output to the bug as well.

see build.txt

MsgPack.zip

build.txt

@patricksuo
Copy link
Author

ping @eerhardt

@patricksuo patricksuo changed the title references to local assembly problem reference local assembly in dotnet core preview 2 Jul 17, 2017
@patricksuo patricksuo changed the title reference local assembly in dotnet core preview 2 reference local assembly in dotnet core 2.0 preview 2 Jul 17, 2017
@eerhardt
Copy link
Member

Instead of using HintPath, would it be possible to put the relative path in the Include?

Reference Include="Dll/MsgPack.dll"

A good way of diagnosing build problems is to "dotnet build /v:diag" and look at the diagnostic output to see what was passed to the compiler. Can you attach a diagnostic log as well?

@patricksuo
Copy link
Author

reproduce on Linux VM. I can't access my mac right now.

uname -a

Linux centos7.local 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

new csproj file:

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

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

        <ItemGroup>
                <Reference Include="Dll\MsgPack.dll">
                </Reference>
        </ItemGroup>
</Project>

build log:
build2.zip

@eerhardt

@patricksuo
Copy link
Author

It's a broken image. Closing.

BTW, will local assembly have first class support in future, like dotnet add package?

mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…0200425.5 (dotnet#1417)

- Microsoft.AspNetCore.Analyzers: 5.0.0-preview.5.20223.18 -> 5.0.0-preview.5.20225.5
- Microsoft.AspNetCore.Mvc.Analyzers: 5.0.0-preview.5.20223.18 -> 5.0.0-preview.5.20225.5
- Microsoft.AspNetCore.Components.Analyzers: 5.0.0-preview.5.20223.18 -> 5.0.0-preview.5.20225.5
- Microsoft.AspNetCore.Mvc.Api.Analyzers: 5.0.0-preview.5.20223.18 -> 5.0.0-preview.5.20225.5

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
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

2 participants