Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate nuget package from .NET 6 MacOS bindings project #12631

Closed
hamarb123 opened this issue Sep 6, 2021 · 3 comments · Fixed by #12900
Closed

Can't generate nuget package from .NET 6 MacOS bindings project #12631

hamarb123 opened this issue Sep 6, 2021 · 3 comments · Fixed by #12900
Labels
dotnet An issue or pull request related to .NET (6) dotnet-pri2 .NET 6: want to have for stable release feature A feature to be implemented
Milestone

Comments

@hamarb123
Copy link

Steps to Reproduce

  1. Create .NET 6 macos bindings project
  2. Add a framework eg. MetalANGLE 0.0.7 (what I'm using)
  3. Build the project with dotnet build --configuration Release -p:GeneratePackageOnBuild=true -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:DebugSymbols=true -p:DebugType=portable to generate a nuget package

Expected Behavior

The project builds successfully and generates a nuget package.

Actual Behavior

The build fails with the following error:

/usr/local/share/dotnet/sdk/6.0.100-rc.2.21425.12/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(221,5): error NU5026: The file '/Users/Hamish/Projects/Tests/TestBindingsProject2/TestBindingsProject/bin/Release/net6.0-macos/Native.TestBindingsProject.manifest' to be packed was not found on disk. [/Users/Hamish/Projects/Tests/TestBindingsProject2/TestBindingsProject/TestBindingsProject.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/6.0.100-rc.2.21425.12/Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets(221,5): error NU5026: The file '/Users/Hamish/Projects/Tests/TestBindingsProject2/TestBindingsProject/bin/Release/net6.0-macos/Native.TestBindingsProject.manifest' to be packed was not found on disk. [/Users/Hamish/Projects/Tests/TestBindingsProject2/TestBindingsProject/TestBindingsProject.csproj]

Environment

Visual Studio Community 2022 for Mac Preview
Version 17.0 Preview (17.0 build 2706)
Installation UUID: 93d39ea7-8431-4eae-9b2f-0b0bd10e30da
	GTK+ 2.24.23

Mono Framework MDK
Runtime:
	Mono 6.12.0 (2020-02/eb4c3116ebf) (64-bit)
	Package version: 612000147

Roslyn (Language Service)
3.10.0-3.21226.12+c153357eb74f4b5c8fc905b7ae42168b76515531

NuGet
Version: 6.0.0.129

.NET SDK
SDK: /usr/local/share/dotnet/sdk/6.0.100-rc.2.21425.12/Sdks
SDK Versions:
	6.0.100-rc.2.21425.12
	6.0.100-rc.1.21417.3
	6.0.100-rc.1.21403.66
	6.0.100-preview.7.21379.14
	5.0.400
	3.1.412
	3.0.103
	2.2.207
	2.1.817
MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	6.0.0-rc.2.21423.6
	6.0.0-rc.1.21415.6
	6.0.0-rc.1.21401.3
	5.0.9
	3.1.18
	3.0.3
	2.2.8
	2.1.29

.NET 5.0 SDK
SDK: 5.0.400

.NET Core 3.1 SDK
SDK: 3.1.412

Xamarin.Profiler
Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin Designer
Version: 17.0.0.58
Hash: 927d548a1
Branch: remotes/origin/d17-0
Build date: 2021-08-27 11:27:00 UTC

Apple Developer Tools
Xcode 13.0 (19223.2)
Build 13A5212g

Xamarin.Mac
Version: 7.14.0.24 (Visual Studio Community)
Hash: c4b89cddb
Branch: d16-10
Build date: 2021-06-15 22:03:00-0400

Xamarin.iOS
Version: 14.20.0.24 (Visual Studio Community)
Hash: c4b89cddb
Branch: d16-10
Build date: 2021-06-15 22:03:01-0400

Xamarin.Android
Version: 11.3.99.54 (Visual Studio Community)
Commit: xamarin-android/main/0e5e06f
Android SDK: /Users/Hamish/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 31.0.2
SDK Build Tools Version: 30.0.2

Build Information: 
Mono: c633fe9
Java.Interop: xamarin/java.interop/main@a5ed891
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.35.4@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@683f375

Microsoft OpenJDK for Mobile
Java SDK: /Users/Hamish/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.0.0.3
Hash: f06a85b
Branch: remotes/origin/HEAD
Build date: 2021-08-27 11:27:02 UTC

Android Device Manager
Version: 17.0.0.2
Hash: d8af29f
Branch: remotes/origin/main
Build date: 2021-08-27 11:27:02 UTC

Build Information
Release ID: 1700002706
Git revision: ba899d0dec8c3161225334edfcc5569ebfae78cc
Build date: 2021-08-27 07:26:10-04
Build branch: release-17.0

Operating System
Mac OS X 11.5.2
Darwin 20.6.0 Darwin Kernel Version 20.6.0
    Wed Jun 23 00:26:31 PDT 2021
    root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

Build Logs

msbuild.log.zip

Example Project (If Possible)

TestBindingsProject2.zip
Note, before building this project, you need to first extract the zip at TestBindingsProject/Natives/MetalANGLE.framework.mac.zip first using Archive Utility (other unarchivers may also work) - it should create a folder called MetalANGLE.framework in the Natives folder (same structure as the framework for the project in #12630).

@rolfbjarne rolfbjarne added this to the .NET 6 milestone Sep 6, 2021
@rolfbjarne rolfbjarne added dotnet An issue or pull request related to .NET (6) dotnet-pri2 .NET 6: want to have for stable release feature A feature to be implemented labels Sep 6, 2021
@rolfbjarne
Copy link
Member

I'm not quite sure if this is a bug or if we just have to figure out how to to do (and then document it), but I'm keeping it open so that we can investigate.

@hamarb123
Copy link
Author

hamarb123 commented Sep 20, 2021

I've got a temporary workaround. It is the following:
In csproj:

<!--Temporary workaround for https://github.com/xamarin/xamarin-macios/issues/12631-->
<PropertyGroup Condition=" '$(MakingNugetPackage)' == 'true' ">
	<IsBindingProject></IsBindingProject>
</PropertyGroup>
<ItemGroup Condition=" '$(MakingNugetPackage)' == 'true' ">
	<None Remove="@(None)" />
	<Folder Remove="@(Folder)" />
	<Compile Remove="@(Compile)" />
	<ObjcBindingApiDefinition Remove="@(ObjcBindingApiDefinition)" />
	<ObjcBindingCoreSource Remove="@(ObjcBindingCoreSource)" />
	<NativeReference Remove="@(NativeReference)" />
</ItemGroup>

And then to make a nupkg (and a snupkg), you build with the following script: build_macos_native.sh.zip. The script essentially builds a fake version of the library and then puts the real dll, xml and pdb into the nupkg and snupkg.

If you were to use it, you'd obviously need to update the paths and filenames in the script though (and possibly other things).

I've tested it and it seems to work properly when referenced with PackageReference.

Aside: Interestingly <IsBindingProject>false</IsBindingProject> (in the csproj above) didn't seem to properly disable it being a binding project since I still got errors about there being no api definitions file specified.

@hamarb123
Copy link
Author

Possible fix: I noticed that novotnyllc/MSBuildSdkExtras#176 is almost exactly the same thing as the error I'm getting (except for file names and line numbers), so perhaps whatever fixed it can pretty much be copied and pasted here (seems like a simple fix there).

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Oct 1, 2021
Add support for 'dotnet pack', by:

1. Add a workaround for the fact that as soon as a project has a
   'NativeReference' item, .NET's MSBuild logic wants to include a
   'Native.$(AssemblyName).manifest' file in the NuGet. This obviously breaks,
   because we don't create such a file, so we work around it by removing the
   file in question from the corresponding item groups.

2. Add any binding resource packages to the NuGet.

3. Add tests.

Fixes dotnet#12631.
rolfbjarne added a commit that referenced this issue Oct 4, 2021
Add support for 'dotnet pack', by:

1. Add a workaround for the fact that as soon as a project has a
   'NativeReference' item, .NET's MSBuild logic wants to include a
   'Native.$(AssemblyName).manifest' file in the NuGet. This obviously breaks,
   because we don't create such a file, so we work around it by removing the
   file in question from the corresponding item groups.

2. Add any binding resource packages to the NuGet.

3. Add tests.

Fixes #12631.
@ghost ghost locked as resolved and limited conversation to collaborators Apr 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dotnet An issue or pull request related to .NET (6) dotnet-pri2 .NET 6: want to have for stable release feature A feature to be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants