Skip to content

Bundle resources in NuGet package not installed #7258

Closed

Description

@babak-f

I have a NuGet package with a number of files, that should be added to the source code of the target package as bundle resource. But they don't get added.

The NuGet package does not contain a Visual Studio solution (sln), i.e. contains just files.

Steps to Reproduce

  1. Create a NuGet package that contains a number of files. Nuspec file:
<package>
  <metadata>
    <id>...</id>
    <version>...</version>
    <title>...</title>
    <authors>...</authors>
    <owners>...</owners>
    <requireLicenseAcceptance>...</requireLicenseAcceptance>
    <description>...</description>
    <copyright>...</copyright>
    <tags>...</tags>
    <dependencies>
    </dependencies>
    <contentFiles>
      <files include="Resources\*" buildAction="BundleResource" flatten="true" />
    </contentFiles>	
  </metadata>
  <files>
    <file src="Folder1\**\*.*" target="content\Resources\Folder1" />
    <file src="Folder2\**\*.*" target="content\Resources\Folder2" />		
  </files>
</package>
  1. Publish the NuGet package to a package repository
  2. Create a Xamarin iOS project
  3. Install the NuGet package in this project

Expected Behavior

The files be copied into the Resources folder of the Xamarin project's source code, with "bundle resource" as build action.

OR:

The files be copied to the iOS app's target directory as bundle resource, upon buidling the app.

Actual Behavior

No files are copied to the Resources folder. The bundle resources are not present either, once you run the app. I.e., the files are not installed in neither the source directory nor the output directory.

Environment

Microsoft Visual Studio Professional 2019
Version 16.3.5
VisualStudio.16.Release/16.3.5+29411.108
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Professional

Mono Debugging for Visual Studio   16.3.7 (9d260c5)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   5.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Xamarin.iOS and Xamarin.Mac SDK   13.4.0.2 (e37549b)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Xamarin   16.3.0.277 (d16-3@c0fcab7)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Also fails on Visual Studio for Mac (latest version).

But it does not fail on Visual Studio for Windows 2017.

Build Logs

No error is logged by the NuGet package installation, and it says that package installation was successful.

Other Remarks

Tried setting the build action to Content (in the nuspec file), which didn't work either.

Activity

  1. whitneyschmidt commented on Oct 24, 2019

    @whitneyschmidt
    Contributor

    @babak-f Thank you for your feedback!

    For us to investigate this further, could you please provide your full build logs, crash reports (if any), solution files (to reproduce) and all your version information. For your issue, it would also be useful if you could include the Nuget package that you are installing.

    To get full build logs just set the log verbosity to diagnostic at the following locations:

    • On Visual Studio for Mac: Preferences > Projects > Build
    • On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

    On Visual Studio for Windows you also want to add -v -v -v -v to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting Properties.

    Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

    The easiest way to get exact version information:

    • On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
    • On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.

    Then copy/paste the version information (you can use the "Copy Information" button).

    We look forward to hearing from you!

  2. added
    need-info
    on Oct 24, 2019
  3. added this to the Future milestone on Oct 24, 2019
  4. PTEC3D50 commented on Nov 6, 2019

    @PTEC3D50

    Hello there, we have the same issue with our NuGet, we need to include a custom font for our views but we don't add successfully the file.

    We use the tutorial from James Montemagno (https://montemagno.com/converting-xamarin-libraries-to-sdk-style-multi-targeted-projects/) for our project, but I try to use the nuspec method but neither the csproj Nuget and the nuspec Nuget have the file. Could you give us some updates ?
    Thanks for your time.

    NugetTrackResource.zip

  5. jamesmontemagno commented on Nov 8, 2019

    @jamesmontemagno
    Member

    So, you are using multi-targeting here with SDK Extras: https://github.com/onovotny/MSBuildSdkExtras usually I would ask questions there as there are special flags usually you need to set to get things packages and it is a third party library.

    You will want to update to 2.0.54 to ensure all files are picked up for sure. For Android items the naming of the folder is very important such as how we use it in Essentials: https://github.com/xamarin/Essentials/blob/master/Xamarin.Essentials/Xamarin.Essentials.csproj#L76

    I am not sure about iOS, but can ask @onovotny if he has done it

  6. jamesmontemagno commented on Nov 10, 2019

    @jamesmontemagno
    Member
  7. chamons commented on Nov 11, 2019

    @chamons
    Contributor

    It sounds like this is a naming issues and not a macios bug, so I'm going to close it for now.

  8. ghost locked as resolved and limited conversation to collaborators on May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-info

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions