Create nuget package and installing issues - installation

I created a nuget package, all seems to be ok (no error message), when I install it from Package Manager Console, the dll is in XXX/lib/lib ... I don't know why there are two lib folder ??? I tried to change my nuspec with several solutions but I always had the same folder
<package>
<metadata>
<id>Telerik.Reporting.OpenXmlRendering</id>
<version>8.1.14.804</version>
<title>Telerik.Reporting.OpenXmlRendering</title>
<authors>XXXXX</authors>
<owners>XXXXX</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Assembly XXXX</description>
<copyright>Copyright XXXX</copyright>
<references></references>
<tags></tags>
</metadata>
<files>
<file src="*.dll" target=".\" />
</files>
</package>
I tried
<file src="*.dll" target="lib\net45" />
<file src="*.dll" target="lib\" />
<file src="*.dll" target="" />
And the installed always put the dll in :
C:\XXXXXX\packages\Telerik.Reporting.OpenXmlRendering.8.1.14.804\lib\lib
Do you have any ideas ?
Thanks

Related

How to create my own custom nuget package for System.Data.SQLite to correctly include the interop dlls?

I want to create my own custom package for System.Data.SQLite. I have the all the dll's I need but I'm unsure how to structure it and create the nuspec for it.
Current folder structure of the dll's is this, whereabouts would I put the different interop dlls to have them copied correctly to the output and what do I need to add to the nuspec?
lib/net452
-> System.Data.SQLite.dll , System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll
Custom.SQLite.nuspec
Still have the default nuspec something like this atm
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
</package>
SQLite.Interop.dll does not act as a lib assembly dll. That is not its role. And it should be a content file rather than a assembly dll. So it should not be packed as lib.
To create such custom nuget package, you should first pack System.Data.SQLite.dll, System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll as lib. See this document.
and then pack SQLite.Interop.dll as content.
Also, to make the content file be copied into the output folder of the main project when you install the nuget package, you have to use a <packages_id>.props or targets file to realize it.
1) create a file called <packages_id>.props into your class library project. And it should be the same name as your nuget package. In your side, it should be named as Custom.SQLite.Name.props. Otherwise, it will not work.
And then add these into the file:
<Project>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\content\x86\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)..\content\x64\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2) use this nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
<files>
<file src="System.Data.SQLite.dll" target="lib\net452" />
<file src="System.Data.SQLite.EF6.dll" target="lib\net452" />
<file src="System.Data.SQLite.Linq.dll" target="lib\net452" />
<file src="xxx\x86\SQLite.Interop.dll" target="content\x86" />
<file src="xxx\x64\SQLite.Interop.dll" target="content\x64" />
<file src="Custom.SQLite.Name.props" target="build" />
</files>
</package>
3) rebuild your lib project and then use nuget pack to pack the new version.
Before you use this new version, please uninstall the old one and delete all cache files under C:\Users\xxx\.nuget\packages\Custom.SQLite.Name and <solution_folder>\packages\Custom.SQLite.Name.1.0.0. Then, reinstall the new version.

VS2017 nuget keeps searching for packages in wrong location

So I migrated from nuget packages.config to PackageReference and found out there were some compatibility issues. I reverted the project to its working state (before the PackageReference) and now my project is not compiling.
I get the following error:
Severity Code Description Project File Line Suppression State
Error The package EntityFramework with version 6.2.0 could not be found in C:\Users\user.nuget\packages. Run a NuGet package restore to download the package. DbManager
This happened to multiple packages. It seems that Nuget is searching for packages in the user.net\package directory for some reason. Originally, there was a folder within the project that contained all the packages.
I forced the global path to be at the folder within the project by editing the NuGet.Config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="C:\Projects\App\App Source\packages\" />
<add key="globalPackagesFolder" value="C:\Projects\App\App Source\packages\" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
I don't know why Nuget keeps looking for packages at that location. It should be looking at the packages folder within the project.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="EntityFramework6.Npgsql" version="3.1.1" targetFramework="net46" />
<package id="Npgsql" version="3.2.7" targetFramework="net46" />
<package id="System.Threading.Tasks.Extensions" version="4.3.0" targetFramework="net46" />
<package id="Z.EntityFramework.Plus.EF6" version="1.7.17" targetFramework="net46" />
</packages>
All of these packages in packages.config are not being found. This problem started happening when I tried PackageReference.
Is there any way to reset Nuget's settings? I would appreciate any guidance in solving this problem.
TLDR; This is caused by latent copies of the new project.assets.json file being left in your /obj/ folders. These can be safely deleted.
You can run this Powershell (at your own risk) in your root solution folder as a quick way to purge these files:
ls project.assets.json -Recurse | foreach {rm $_}
project.assets.json is generated for projects using PackageReference to cache the Nuget dependency graph for your project. It seems to confuse Visual Studio/Nuget if it's left there even if your project is using (or reverted back to using) packages.config
This can happen in Visual Studio 2019 as well, if you try PackageReference and then revert back to packages.config (or even if you switch between Git branches with one Nuget restore method versus the other).
Further Info
More info on project.assets.json here:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x

Dotfuscator command exited with code 1 xamarin.ios

I am trying to use PreEmptive Solutions - Dotfuscator with my Xamarin.IOS app, but the build fails and I am getting this error:
I have done all the steps from here:
https://www.preemptive.com/obfuscating-xamarin-with-dotfuscator
My Xamarin.Android works fine, but the IOS project fails.
The error:
The command ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\PreEmptive Solutions\Dotfuscator and Analytics Community Edition\dotfuscatorCLI.exe" /p:InDir="obj\iPhone\Release\DotfuscatorXamarin\dfin",OutDir="obj\iPhone\Release\DotfuscatorXamarin\dfout",ReportDir="DotfuscatorReports\iPhone\Release" "DotfuscatorConfig.xml"" exited with code 1.
Any idea how I can fix it?
Update 29-06-2017:
Content of DotfuscatorConfig.xml file for the Xamarin.IOS project
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE dotfuscator SYSTEM "http://www.preemptive.com/dotfuscator/dtd/dotfuscator_v2.3.dtd">
<dotfuscator version="2.3">
<propertylist>
<property name="InDir" value="obj\iPhone\Release\DotfuscatorXamarin\dfin" />
<property name="OutDir" value="obj\iPhone\Release\DotfuscatorXamarin\dfout" />
<property name="ReportDir" value="DotfuscatorReports\iPhone\Release" />
</propertylist>
<global>
<option>monocompat</option>
</global>
<input>
<asmlist>
<inputassembly refid="7cf160e1-e28e-4f81-bd8d-f10fdcbcc3f8">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="${configdir}\${InDir}" name="MyProject.dll" />
</inputassembly>
<inputassembly refid="2d40ee83-3b30-421c-8b1a-fa4d404fb2d9">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="${configdir}\${InDir}" name="MyProject.dll.mdb" />
</inputassembly>
<inputassembly refid="11652964-9a02-4f24-b042-25f260fada88">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="${configdir}\${InDir}" name="MyProject.iOS.exe" />
</inputassembly>
</asmlist>
</input>
<output>
<file dir="${configdir}\${OutDir}" />
</output>
<renaming>
<option>xmlserialization</option>
<mapping>
<mapoutput overwrite="true">
<file dir="${configdir}\${ReportDir}" name="Renaming.xml" />
</mapoutput>
</mapping>
<referencerulelist>
<referencerule rulekey="{6655B10A-FD58-462d-8D4F-5B1316DFF0FF}" />
<referencerule rulekey="{7D9C8B02-2383-420f-8740-A9760394C2C1}" />
<referencerule rulekey="{229FD6F8-5BCC-427b-8F72-A7A413ECDF1A}" />
<referencerule rulekey="{2B7E7C8C-A39A-4db8-9DFC-6AFD38509061}" />
<referencerule rulekey="{494EA3BA-B947-44B5-BEE8-A11CC85AAF9B}" />
<referencerule rulekey="{89769974-93E9-4e71-8D92-BE70E855ACFC}" />
<referencerule rulekey="{4D81E604-A545-4631-8B6D-C3735F793F80}" />
</referencerulelist>
</renaming>
<sos mergeruntime="true">
<option>version:v4</option>
<option>disable</option>
<option>dontsendtamper</option>
</sos>
<smartobfuscation>
<smartobfuscationreport verbosity="all" overwrite="true">
<file dir="${configdir}\${ReportDir}" name="SmartObfuscation.xml" />
</smartobfuscationreport>
</smartobfuscation>
</dotfuscator>
And for PreEmptive.Dotfuscator.Xamarin.targets file, I am using the one from the offical website.
PreEmptive.Dotfuscator.Xamarin.targets
As mentioned in the comments to the question, I work for PreEmptive Solutions.
This is a bug in the Dotfuscator-Xamarin targets file (PreEmptive.Dotfuscator.Xamarin.targets), so sorry about that.
Note: This issue has been corrected in version 1.1.0 of the targets file. The latest version of the file can be downloaded on this page.
Specifically, when generating the initial Dotfuscator config file (DotfuscatorConfig.xml), we were treating an MDB (Mono debug symbol) file as an input assembly.
The next version of the targets file will correct this issue.
To resolve this issue with version 1.0.0 of the targets file, please delete the following lines from DotfuscatorConfig.xml:
<inputassembly refid="2d40ee83-3b30-421c-8b1a-fa4d404fb2d9">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="${configdir}\${InDir}" name="MyProject.dll.mdb" />
</inputassembly>
The targets file will use your corrected version from then on.

My nupkg is incompatible with my Unified API app

I've made a NuGet package that has a lib/Xamarin.iOS10 folder with a dll inside it.
I've created a test project (an iOS unified API Single View App) and I try to add my package but I get this response:
Could not install package 'mypackage 1.0'. You are trying to install
this package into a project that targets 'Xamarin.iOS,Version=v1.0',
but the package does not contain any assembly references or content
files that are compatible with that framework. For more information,
contact the package author.
Extracting the file, I can verify that my dll is present.
This is the nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8">
<id>MyPackage</id>
<version>1.0</version>
<title>My Package</title>
<authors>Kristian</authors>
<owners>Kristian</owners>
<developmentDependency>true</developmentDependency>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Experiment Package</description>
<summary />
<language>en-US</language>
<tags></tags>
<dependencies>
<dependency id="Fody" version="1.29.3"/>
</dependencies>
</metadata>
<files>
<file src="../MyPackage.XamarinIOS/bin/iPhone/Release/MyPackage.dll" target="lib/Xamarin.iOS10/MyPackage.dll" />
</files>
</package>
Is there anything else I need to do? I am not using the new project.json format for my package.. I am using Xamarin Studio version 5.9.8.
Shouldn't that be:
target="lib/xamarinios10/MyPackage.dll"
Instead of your Xamarin.iOS10 path?

WiX 3.8 website installer - nothing happens on executing MSI

I am using WiX 3.8 to build a website installer for a MVC web API project. I have successfully followed the steps of a tutorial and created the MSI file that should just copy all the web app files to my IIS folder. However on executing it, I don't see any files copied and the MSI exits without any error. I checked in the event log as well, where it says that the installer ran successfully. Below is the MS Build file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebSiteSource>..\API\</WebSiteSource>
<SetupF>..\Setup\</SetupF>
<PublishF>publish\</PublishF>
<Publish>$(SetupF)$(PublishF)</Publish>
<WebSiteContentCode>WebAPIContent.wxs</WebSiteContentCode>
<WebSiteContentObject>WebSiteContent.wixobj</WebSiteContentObject>
<MsiOut>bin\Release\Setup.msi</MsiOut>
</PropertyGroup>
<!-- Defining group of temporary files which is the content of the web site. -->
<ItemGroup>
<WebSiteContent Include="$(WebSiteContentCode)" />
</ItemGroup>
<!-- The list of WIX input files -->
<ItemGroup>
<WixCode Include="Product.wxs" />
<WixCode Include="$(WebSiteContentCode)" />
</ItemGroup>
<Target Name="Build">
<!-- Compile in release mode -->
<MSBuild Projects="..\API\API.csproj" Targets="ReBuild" Properties="Configuration=Release" />
</Target>
<Target Name="PublishWebsite">
<!-- Remove complete publish folder in order to be sure that evrything will be newly compiled -->
<Message Text="Removing publish directory: $(SetupF)"/>
<RemoveDir Directories="$(SetupF)" ContinueOnError="false" />
<Message Text="Start to publish website" Importance="high" />
<MSBuild Projects="..\API\API.csproj" Targets="ResolveReferences;_CopyWebApplication" Properties="OutDir=$(Publish)bin\;WebProjectOutputDir=$(Publish);Configuration=Release" />
</Target>
<Target Name="Harvest">
<!-- Harvest all content of published result -->
<Exec
Command='"$(Wix)bin\heat" dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg apicomponents -var var.publishDir -gg -out $(WebSiteContentCode)'
ContinueOnError="false"
WorkingDirectory="." />
</Target>
<Target Name="WIX">
<Message Text="TEST: #(WixCode)"/>
<Exec
Command='"$(Wix)bin\candle" -dpublishDir=$(Publish) -dMyWebResourceDir=. #(WixCode, &apos; &apos;)'
ContinueOnError="false"
WorkingDirectory="." />
<Exec
Command='"$(Wix)bin\light" WebAPIContent.wixobj Product.wixobj -out $(MsiOut)'
ContinueOnError="false"
WorkingDirectory="." />
<Message Text="Install package has been created." />
</Target>
</Project>
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="ApiSetup" Language="1033" Version="1.0.0.0" Manufacturer="Fingent" UpgradeCode="20e8d558-9fc4-4bd3-9842-76ae40edd994">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of API is already installed." />
<Media Id="1" Cabinet="api.cab" EmbedCab="yes" />
<Feature Id="ProductFeature" Title="api.Setup" Level="1">
<ComponentGroupRef Id="apicomponents" />
</Feature>
</Product>
<Fragment>
<!-- Will default to C:\ if that is the main disk -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Will reference to C:\wwwroot-->
<Directory Id="INETPUB" Name="Inetpub">
<!-- Will reference to c:\wwwroot\api-->
<Directory Id="INSTALLFOLDER" Name="api" />
</Directory>
</Directory>
</Fragment>
</Wix>
As you can see I have used Heat to generate the files list. The WXS file for it is correctly generated and I also get the OBJ files and the MSI, but nothing is done after its execution. Please help.
The problem might be due to following reasons:
1) In HeatFile.wxs generation. The HeatFile.wxs might have been generated successfully but it may not contain the directory to which the software needs to be installed.
For this, add -dr yourinstallationdirectory tag to your command line while generating HeatFile.wxs.
Complete command looks like:
heat.exe dir "path to directory which needs to be harvested" -dr INSTALLDIR -cg Components -gg -g1 -srd -var var.MyDir -out HeatFile.wxs
2) However, you found that your TARGETDIR turns out to be D:\ drive. This happens because wix search for the Directory with most free disk space and install your msi in that directory by default.
But you can change your root directory using the following tag:
< SetDirectory Id="TARGETDIR" Value="C:\" / >
Hope this helps :)

Resources