How to reference a csproj using csc?

321 Views Asked by At

Using csc how can I reference another project's source?

If I have my own .csproj for a hefty project that depends on another, and am compiling the dependent with dotnet build rather than csc I can add

<ItemGroup>
  <ProjectReference Include="..\MyAPI\MyAPI.csproj" />
</ItemGroup>

To the csproj file, but what about in the case of writing a single .cs file?

csc test.cs /reference:../MyAPI/MyAPI.csproj

doesn't work because

error CS0009: Metadata file '/Users/me/MyAPI/MyAPI.csproj' could not be opened -- PE image doesn't contain managed metadata.
test.cs(2,7): error CS0246: The type or namespace name 'MyAPI' could not be found (are you missing a using directive or an assembly reference?)

0

There are 0 best solutions below