4

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?

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
theonlygusti
  • 11,032
  • 11
  • 64
  • 119

2 Answers2

4

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

2

You need to use dotnet add reference

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

dotnet add reference -h|--help
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197