I'm building a nuget package and all is well until I try to use the wildcard to import all dll's in a folder.
This works perfectly
<file src="KL.Ocr.Tesseract/x86/liblept172.dll" target="content\x86"/>
however this does nothing
<file src="KL.Ocr.Tesseract/x86/*.dll" target="content\x86"/>
Any help would be appreciated (and I am intentionally placing the dll's in content instead of lib because thats where they need to be)
<?xml version="1.0"?>
<package >
<metadata>
<id>asdf</id>
<version>1.0.0.0</version>
<title>asdf</title>
<authors>asdf</authors>
<owners>asdf</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>asdf </description>
<copyright>Copyright 2016</copyright>
<tags>asdf</tags>
<frameworkAssemblies>
</frameworkAssemblies>
<dependencies>
</dependencies>
</metadata>
<files>
<file src="KL.Pas.Ocr.targets" target="build"/>
<file src="KL.Ocr.Pas.Host/bin/Debug/KL.Ocr.Pas.Host.dll" target="lib/net45" />
<file src="KL.Ocr.Pas.Host/bin/Debug/KL.Ocr.Pas.Worker.exe" target="lib/net45" />
<file src="KL.Ocr.Pas.Host/bin/Debug/KL.Pas.Ocr.Contracts.dll" target="lib/net45" />
<file src="KL.Ocr.Pas.Host/bin/Debug/KL.Ocr.Tesseract.dll" target="lib/net45" />
<file src="KL.Ocr.Pas.Host/bin/Debug/Tesseract.dll" target="lib/net45" />
<file src="KL.Ocr.Tesseract/x64/*.dll" target="build\x64"/>
<file src="KL.Ocr.Tesseract/x86/*.dll" target="build\x86"/>
<file src="KL.Ocr.Tesseract/tessdata/*.*" target="build\tessdata"/>
</files>
</package>
I am assuming you are generating the NuGet package on Windows.
If you switch to using backslash instead of forward slashes then it will work.
<file src="KL.Ocr.Tesseract\x64\*.dll" target="build\x64"/>
The above works fine. Using forward slashes does not seem to work.
Related
Can anybody help me find out why my Windows service won't start.
When I install it with installutil, it works perfectly. I decided to use wix to create an installer for the end user but it won't start.
Here's my code
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IWErpnextPoll" Manufacturer="IWW" Language="1033" Version="1.0.0.0" UpgradeCode="ccc3c2fe-d20f-45ce-b978-4dc7c84ce6c8">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="IWERPNextPoll_Setup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="IWErpnextPoll" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Source="$(var.IWErpnextPoll.TargetPath)" />
<ServiceInstall Id="ServiceInstaller" Name="IWErpnextPoll" Type="ownProcess" Vital="yes" DisplayName="ERPNext2Sage" Description="A background service." Start="auto" Account=".\LocalSystem" ErrorControl="normal" Interactive="no" />
<ServiceControl Id="StartService" Name="IWErpnextPoll" Stop="both" Start="install" Remove="uninstall" Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
The installer throws this error:
Service 'IWErpnextPoll' (IWErpnextPoll) failed to start. Verify that you have sufficient privileges to start system services
I ran the following in the command line:
msiexec /i IWERPNextPoll_Setup /l*v log.txt
but (my untrained eyes) didn't find anything that seemed off in the very very log file.
The service I wrote is my first forray into C#. I'll be very happy to get any pointers.
99.99% of the time this is a problem with the service.
A couple of pro tips.
1) Don't author the ServiceControl element for the first few builds until you know the thing is solid. Test the service after installation.
2) If you do author it, let it sit on the failed to start dialog and start profiling. Run the EXE from a command prompt and see if it is missing dependencies or throws errors. Have lots of logging code in the service to understand what is wrong.
ServiceInstaller is a form of self registration anti pattern. Perhaps you had some code in there doing something like creating an EventSource or a registry key and without it your service is throwing an exception.
Only profiling/debugging will tell for sure.
The answer by #Christopher Painter and the comments on my question led me towards the problem.
The problem was that I did not include my project dependencies in product.wsx. I had to add like so...
...
<Component Id="Serilog.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.dll" />
</Component>
<Component Id="Serilog.Settings.AppSettings.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.Settings.AppSettings.dll" />
</Component>
<Component Id="Serilog.Sinks.File.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)Serilog.Sinks.File.dll" />
</Component>
<Component Id="RestSharp.dll">
<File Source="$(var.IWErpnextPoll.TargetDir)RestSharp.dll" />
</Component>
...
After this, things started working as expected
I've created a nuget package targeting a .NET Core project.
The idea here is to add xxx.dll as a reference with copy local as false
and copy all DLLs in a subfolder in the output path and all resources files in subfolder\resources
The nuspec targeting NET Core 3 is working fine.
Now I want to do the same to target NET Framework 4.6.1.
But the content files are not added to the project.
This is my nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>xxx.Win.x64.ForIPS11</id>
<version>15.5.3.4</version>
<title>xxx toolkit</title>
<authors>xxx Team</authors>
<owners>xxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>xxx 15.5.3.4 x64 Windows to .NETFramework 4.6.1 for IPS 11</description>
<releaseNotes></releaseNotes>
<copyright>2020</copyright>
<tags></tags>
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
</dependencies>
<contentFiles>
<files include="**\subfolder\resources\*.*" buildAction="Content" copyToOutput="true" />
<files include="**\subfolder\*.dll" buildAction="Content" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="bin\xxx.dll" target="lib\net461" />
<file src="resources\*.*" target="contentFiles\any\any\subfolder\resources" />
<file src="bin\*.dll" target="contentFiles\any\any\subfolder" />
</files>
</package>
Did I use an incompatible tag for .NET Framework target?
Any idea how to get this done?
EDIT : I use packages.config file in VS2017 in the target project
contentFiles is not compatible with packages.config way
This is an alternative :
Nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>xxx.Win.x64.ForIPS11</id>
<version>0.0.0</version>
<title>xxx toolkit</title>
<authors>xxx Team</authors>
<owners>xxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>xxx 0.0.0 x64 Windows to .NETFramework 4.6.1</description>
<releaseNotes></releaseNotes>
<copyright>2020</copyright>
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
</dependencies>
<tags></tags>
</metadata>
<files>
<file src="bin\xxx.dll" target="lib\net461" />
<file src="resources\*.*" target="build\subfolder\resources" />
<file src="bin\*.dll" target="build\subfolder" />
<file src="xxx.Win.x64.targets" target="build" />
<file src="install.ps1" target="tools" />
</files>
</package>
xxx.Win.x64.targets to copy subfolder to output
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.*" />
<None Include="#(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
and install.ps1 to mark copy local false to the reference
param($installPath, $toolsPath, $package, $project)
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
$reference.CopyLocal = $false;
}
}
I have a nuget package that uses the Apose.PDF package which I have a license for. The license is put in a separate file called Aspose.Total.lic and is located in the same folder The folder structure is like this.
Project
-PDFReader.cs
-Aspose.Total.lic
The PDFReader.cs has the following code to read the license:
static PDFReader()
{
var license = new License();
license.SetLicense("Aspose.Total.lic");
}
And all this works fine locally. But when I export my code to a Nuget package and use the package from another program, I get exceptions that it cannot find "Aspose.Total.lic" Copying the contents of the file and putting it as argument for SetLicense does not work, it expects a file. Now the question is, how and maybe where do I export the file when packing a nuget package? This is my nuspec file (some code is abbreviated):
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>XYZ</id>
<version>1.3.7</version>
<summary />
<dependencies>
<dependency id="Aspose.PDF" version="18.10.0" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" />
<frameworkAssembly assemblyName="System.Data" />
</frameworkAssemblies>
</metadata>
<files>
<file src="XYZ\bin\Release\XYZ.dll" target="lib\net47\XYZ.dll" />
<file src="XYZ\Aspose.Total.lic" target="lib\Aspose.Total.lic" />
</files>
</package>
My guess here is the the target location is wrong for the file.
NuGet exposes 3 folder automatically, lib for dlls, tools for powershell scripts and content for other content. (I think - it's been a while)
Try changing :
<files>
<file src="XYZ\bin\Release\XYZ.dll" target="lib\net47\XYZ.dll" />
<file src="XYZ\Aspose.Total.lic" target="lib\Aspose.Total.lic" />
</files>
To :
<files>
<file src="XYZ\bin\Release\XYZ.dll" target="lib\net47\XYZ.dll" />
<file src="XYZ\Aspose.Total.lic" target="content\Aspose.Total.lic" />
</files>
I think you should package that file as content. You can check the documentation how to achive that.
I'm trying to create an installer using WiX. To includes DLLs into .msi package I tryied two different ways. One of these is:
<DirectoryRef Id="SETTINGSDIR">
<Component Id="CMP_CopySettings" Guid="AC7D1AA1-798B-48F5-AF8D-188B1050D47C" KeyPath="yes">
<CreateFolder />
<File Id="DBA.bat" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\A_DB clear.bat" Checksum="yes"/>
<File Id="AConfiguration.xml" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\AConfiguration.xml" Checksum="yes"/>
<File Id="ADB.CE.DEFAULT.sdf" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\ADB.CE.DEFAULT.sdf" Checksum="yes"/>
<File Id="ADB.CE.sdf" Source="$(var.SolutionDir)\scr\A\A.WindowsService\bin\$(var.Configuration)\Settings\A.CE.sdf" Checksum="yes"/>
<RemoveFile Id="RemoveFileSettings" Name="*" On="uninstall"/>
</Component>
</DirectoryRef>
But as you can easily understand, it's very hard write an xml node for each DLL (6 projects with 200+ DLLs for each one).
The second one is faster, but WiX just creates a link to the folder instead of copy DLLs into msi package
<DirectoryRef Id="SETTINGSDIR">
<Component Id="CMP_CopySettings" Guid="AC7D1AA1-798B-48F5-AF8D-188B1050D47C" KeyPath="yes">
<CreateFolder />
<CopyFile Id="SettingsID" SourceProperty="SETTINGSSOURCEDIRECTORY" DestinationDirectory="SETTINGSDIR" SourceName="*" />
<RemoveFile Id="RemoveFileSettings" Name="*" On="uninstall"/>
</Component>
</DirectoryRef>
Is there a quick solution that can I add at my second way or I have to use heat.exe tool? In this case, can you explain me how to use it? The official documentation is very poor
Thanks
What you want is an harvest tool to do this for you. Luckily it already exists: Heat
In your specific case you might want to use the command heat dir ".\My Files" -gg -g1 -directoryid "YourDirectoryId" -sfrag -template:fragment -out directory.wxs but check what is exactly your need, which harvesting you want to skip etc...
Note the -t <xsl> switch which gives you the total control on how you want to tune the final output.
I wont to package one of my DLL in a NuGet package.
This DLL uses Xamarin Forms and will target Android, iOS and UWP (Universal Windows) projects
Here is the section of nuspec file:
<files>
<!--Core-->
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.dll" target="lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.dll" />
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.pdb" target="lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.pdb" />
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.xml" target="lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.xml" />
<!--Xamarin.Android-->
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.dll" target="lib\MonoAndroid10\CBS_CBT.Polux.dll" />
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.pdb" target="lib\MonoAndroid10\CBS_CBT.Polux.pdb" />
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.xml" target="lib\MonoAndroid10\CBS_CBT.Polux.xml" />
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.Droid.dll" target="lib\MonoAndroid10\CBS_CBT.Polux.Droid.dll" />
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.Droid.pdb" target="lib\MonoAndroid10\CBS_CBT.Polux.Droid.pdb" />
<file src="Polux\CBS_CBT.Polux.Droid\bin\Release\CBS_CBT.Polux.Droid.xml" target="lib\MonoAndroid10\CBS_CBT.Polux.Droid.xml" />
<!--Xamarin.iOS-->
<file src="Polux\CBS_CBT.Polux.iOS\bin\iPhone\Release\CBS_CBT.Polux.dll" target="lib\Xamarin.iOS10\CBS_CBT.Polux.dll" />
<file src="Polux\CBS_CBT.Polux.iOS\bin\iPhone\Release\CBS_CBT.Polux.pdb" target="lib\Xamarin.iOS10\CBS_CBT.Polux.pdb" />
<file src="Polux\CBS_CBT.Polux.iOS\bin\iPhone\Release\CBS_CBT.Polux.xml" target="lib\Xamarin.iOS10\CBS_CBT.Polux.xml" />
<file src="Polux\CBS_CBT.Polux.iOS\bin\iPhone\Release\CBS_CBT.Polux.iOS.dll" target="lib\Xamarin.iOS10\CBS_CBT.Polux.iOS.dll" />
<file src="Polux\CBS_CBT.Polux.iOS\bin\iPhone\Release\CBS_CBT.Polux.iOS.xml" target="lib\Xamarin.iOS10\CBS_CBT.Polux.iOS.xml" />
<!--uap-->
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.dll" target="lib\UAP10\CBS_CBT.Polux.dll" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.pdb" target="lib\UAP10\CBS_CBT.Polux.pri" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.xml" target="lib\UAP10\CBS_CBT.Polux.xml" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.UWP.dll" target="lib\UAP10\CBS_CBT.Polux.UWP.dll" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.UWP.pdb" target="lib\UAP10\CBS_CBT.Polux.UWP.pdb" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.UWP.pri" target="lib\UAP10\CBS_CBT.Polux.UWP.pri" />
<file src="Polux\CBS_CBT.Polux.UWP\bin\Release\CBS_CBT.Polux.UWP.xml" target="lib\UAP10\CBS_CBT.Polux.UWP.xml" />
The problem:
When I run the application, only the CBS_CBT.Polux.UWP.dll is copied in the \Debug directory, none of the other files (mainly CBS_CBT.Polx.dll) are copied in the output (\Debug for example) directory. The software then throw:
An exception of type 'System.IO.FileNotFoundException' occurred in
mscorlib.ni.dll but was not handled in user code
Additional information: Could not load file or assembly
'CBS_CBT.Polux, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null'
or one of its dependencies.
When I manually add only "CBS_CBT.Polux.dll" and "CBS_CBT.Polux.UWP.dll" to the references of the UWP project, the software can run without any issue.
Thank you Unni Ravindranathan, after reading the doc, I could correct my code.
The only section I had to change was the "Core" one.
Here is the woring nuspec code:
<!--Core-->
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.dll" target="lib\portable-net45+win8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.dll" />
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.pdb" target="lib\portable-net45+win8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.pdb" />
<file src="Polux\CBS_CBT.Polux\bin\Release\CBS_CBT.Polux.xml" target="lib\portable-net45+win8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\CBS_CBT.Polux.xml" />