user3310334
user3310334

Reputation:

Depend on local C# project

I have two C# projects in the same directory.

.
├── MyLib
│   ├── MyLib.cs
│   ├── MyLib.csproj
│   └── bin
│       └── Debug
│           └── netstandard2.0
│               ├── MyLib.deps.json
│               ├── MyLib.dll
│               └── MyLib.pdb
└── MyApp
    ├── Program.cs
    ├── MyApp.csproj
    └── bin
        └── Debug
            └── netcoreapp2.2
                ├── MyApp.deps.json
                ├── MyApp.dll
                ├── MyApp.pdb
                ├── MyApp.runtimeconfig.dev.json
                └── MyApp.runtimeconfig.json

I would like MyApp to be able to access the classes etc. defined in MyLib.

How do I do that?

I have tried from MyApp

dotnet add package ../MyLib/MyLib.csproj
dotnet add package MyLib --source ../MyLib/bin/Debug

after dotnet pack from MyLib.

None work because the package cannot be found in the source nuget.org.

What's the easiest way for me to simply depend on my local project?

Upvotes: 4

Views: 1420

Answers (2)

Vivek Nuna
Vivek Nuna

Reputation: 1

You need to use dotnet add reference

dotnet add [<PROJECT>] reference [-f|--framework <FRAMEWORK>]
     [--interactive] <PROJECT_REFERENCES>

dotnet add reference -h|--help

Upvotes: 2

user3456014
user3456014

Reputation:

Nearly there. Projects are added by reference -- https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference

Try dotnet add reference ../MyLib/MyLib.csproj

Upvotes: 4

Related Questions