linuxwindows.net-coreshared-projectasp.net-core-cli

Reference shared project in dotnetcore classlib, and have the build work on windows and linux


My goal is to reference a shared project from a dotnetcore class library.

In order to do this I opened my solution that I made on linux with .NET Command Line Tools (1.0.4) in visual studios 2017 on windows, since I read that vs2017 supported references to shprojs. So I added a reference using vs and it added this line to the .netcore libraries csproj file:

<Import Project="..\Objects\LogoRecognitionShared.projitems" Label="Shared" />

At this point I thought everything was going to work perfectly. I build it in visual studios and there where no issues. I thought that since my cli version was the same on windows and linux that the project would be built the same way and support the same functionalities.

However when I tried these changes on linux I received a bunch of "error CS0246: The type or namespace name 'TypeName' could not be found (are you missing a using directive or an assembly reference?)" messages.

I also using the <Compile Include="..\Objects\*.cs"/> statement and got the same error. However if I use both then I get warning CS2002: Source file 'Objects/*.cs' specified multiple times

I am unsure of how to troubleshoot this issue. It seems to me that the build process knows it should be build these files into the output, but when the build actually takes place then it leaves them out and has broken references.

Any help would be fantastic.


Solution

  • Well I think found out what was causing my issues. One of my shared projects had a incorrect RootNamespace value. So I corrected it from vs2017, then did a clean-build and to my surprise it worked on linux...