Search code examples
xamarinvisual-studio-mac

Fresh Xamarin Multiplatform Library fails to build (created from Visual Studio for Mac)


I created a Xamarin Multiplatform Library using Visual Studio for Mac.

Then I just built the MyProject.NuGet project without any change and it fails.

When looking into the error, it shows,

Cannot create a package that has no dependencies nor content.

and also there were these warnings,

warning : The referenced project 'MyProject.Android' does not exist.
warning : The referenced project 'MyProject.iOS' does not exist.

but the MyProject.Android and MyProject.iOS are existing in the solution and they are having reference links in the MyProject.NuGet project too.


Solution

    • In the .NuGet project, open the References, then delete the iOS and Android project references.

      enter image description here

    • Save the solution.

    • Re-add the iOS and Android projects as project references to the .NuGet project.

      enter image description here

    • Try building the .NuGet project now!

    NOTE: Make sure the changes update in the .NuGet.csproj file

    The project reference should have changed from,

    <ProjectReference Include="MyProject.iOS">
      ...
    </ProjectReference>
    <ProjectReference Include="MyProject.Android">
      ...
    </ProjectReference>
    
    

    to

    <ProjectReference Include="..\MyProject.iOS\MyProject.iOS.csproj">
      ...
    </ProjectReference>
    <ProjectReference Include="..\MyProject.Android\MyProject.Android.csproj">
      ...
    </ProjectReference>
    

    in the MyProject.NuGet.csproj file