Reputation: 464
Currently I'm working on an UWP NuGet package for making it easier to create great popups and dialogs. Currently the project is newborn and doesn't have so much controls but I tried to create a NuGet package for it to be a test for making sure it is all good. Unless I'm using app with the class library referenced to the sample project all things working well but after downloading the library from NuGet I'm getting XamlParseException error. I searched a bit and find it out that I should add some xaml, xbf or somethings in the output so I tried to add the following lines to my nuspec.
<files>
<!-- XAML controls -->
<file src="Controls\MessageBoxControls\MessageBoxControl.xaml" target="lib\netcore50\Controls\MessageBoxControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\MessageBoxControls\MessageBoxControl.xbf" target="lib\netcore50\Controls\MessageBoxControls"/>
<file src="Controls\PopupControlControls\PopupControl.xaml" target="lib\netcore50\Controls\PopupControlControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\PopupControlControls\PopupControl.xbf" target="lib\netcore50\Controls\PopupControlControls"/>
<file src="Controls\SlideupPopupControls\SlideupPopup.xaml" target="lib\netcore50\Controls\SlideupPopupControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\SlideupPopupControls\SlideupPopup.xbf" target="lib\netcore50\Controls\SlideupPopupControls"/>
</files>
But still I'm getting same error any idea how to solve it? I should mention that the project is currently available on Github on the following link https://github.com/NGame1/UWPPopupToolkit and the NuGet package also is available here https://www.nuget.org/packages/UWPPopupToolkit
Upvotes: 1
Views: 235
Reputation: 464
Thanks to @Perry Qian-MSFT Finally, I got able to fix the issue. adding files like this
<files>
<!-- Dll -->
<file src="bin\Release\UWPPopupToolkit.dll" target="lib\netcore50" />
<!-- Resources -->
<file src="bin\Release\UWPPopupToolkit.pdb" target="lib\netcore50" />
<file src="bin\Release\UWPPopupToolkit.pri" target="lib\netcore50" />
<!-- IntelliSense -->
<file src="bin\Release\UWPPopupToolkit.XML" target="lib\netcore50" />
<!-- XAML control -->
<file src="bin\Release\UWPPopupToolkit\**\*.*" target="lib\netcore50\UWPPopupToolkit" />
<!-- Icon -->
<!--<file src="..\icon.png" target="images\" />-->
</files>
solved the problem. You can find the result files here: UWPPopupToolkitSDK.nuspec | UWPPopupToolkit.props | UWP Popup Toolkit Github
Upvotes: 1
Reputation: 23740
Simply placing the content files in the lib
folder of the nuget package will not automatically copy it into the build output folder, only the dll
, pdb
and xml
files will be added into the output projects automatically.
Since your additional files are not the same type, so you cannot get what you want by your method. So I suggest you could try this:
Solution
1) create a folder called build
on your root directory of your project and then add a file called <package_id>.props file.
Note: the file must be named the same as your nuget package so that it will work. For an example, if your nuget project named as UWPPopupToolkit.0.0.1-rc.nupkg
, the file must be named as UWPPopupToolkit.props
.
2) add these content into the UWPPopupToolkit.props
file:
<Project>
<Target Name="OutputExtraFiles" BeforeTargets="Build">
<ItemGroup>
<File Include="$(MSBuildThisFileDirectory)..\File\**\*.*"></File>
</ItemGroup>
<Copy SourceFiles="@(File)" DestinationFiles="$(TargetDir)\%(RecursiveDir)%(Filename)%(Extension)"></Copy>
</Target>
</Project>
3) modify your UWPPopupToolkitSDK.nuspec
file like this:
<files>
<!-- XAML controls -->
<file src="Controls\MessageBoxControls\MessageBoxControl.xaml" target="File\Controls\MessageBoxControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\MessageBoxControls\MessageBoxControl.xbf" target="File\Controls\MessageBoxControls"/>
<file src="Controls\PopupControlControls\PopupControl.xaml" target="File\Controls\PopupControlControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\PopupControlControls\PopupControl.xbf" target="File\Controls\PopupControlControls"/>
<file src="Controls\SlideupPopupControls\SlideupPopup.xaml" target="File\Controls\SlideupPopupControls"/>
<file src="bin\Debug\UWPPopupToolkit\Controls\SlideupPopupControls\SlideupPopup.xbf" target="File\Controls\SlideupPopupControls"/>
<file src="build\UWPPopupToolkit.props" target="build" />
</files>
4) then repack your nuget project, before you install the new version of the nuget package, please clean the nuget caches first and also delete the bin
, obj
or any output folders of your main project.
=================================
Update 1
In my side, clean all nuget caches or delete all cache files under C:\Users\xxx(current user)\.nuget\packages
and then install the new version of the nuget package, the target files are output to bin\x86\Debug\Controls
,
If I install the new version 0.0.1.5-rc
,everything works well. See this:
Not sure if your problem is that the files are missing or you want to put them into bin\x86\Debug\netcore50\Controls
.
If your issue is the second, you should modify your UWPPopupToolkit.props
,
use this:
<Copy SourceFiles="@(File)" DestinationFiles="$(TargetDir)netcore50\%(RecursiveDir)%(Filename)%(Extension)"></Copy>
After that, delete bin and obj folder and then rebuild your main project again.
Upvotes: 1