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;
}
}
Related
I created a Wix installer for my web app and am running into an issue when attempting to replace a value in my appsettings.json file (with info that I am getting from the user in a custom dialog I created). The info is getting passed perfectly form my dialog to my custom action. Then it fails and throws an error. Below, I am going to post the error I am getting, the .wixproj file for the installer project, the Produxt.wxs file in the installer project, and most important the CustomAction class from my custom action project. The problem is that I have no idea how to programatically identify the correct file path of the appsettings.json file during the installation process. I am quite lost and could really use some help... Thank you.
Error (being thrown on 2nd line of AddOrUpdateAppSetting method in CustomActions.cs)
ex = {"Could not find file 'C:\\Users\\DeanFriedland\\AppData\\Local\\Temp\\MSI8E19.tmp-\\appSettings.json'.":"C:\\Users\\DeanFriedland\\AppData\\Local\\Temp\\MSI8E19.tmp-\\appSettings.json"}
.wixproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>79a05790-9945-41e3-888d-01b39ed87514</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>OpenBotInstaller-$(Configuration)-$(Platform)</OutputName>
<OutputType>Package</OutputType>
<Cultures>;</Cultures>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Components.wxs" />
<Compile Include="ComponentsGenerated.wxs" />
<Compile Include="DatabaseConfigDialog.wxs" />
<Compile Include="Directories.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Common.wxl" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InstallerCustomAction\InstallerCustomAction.csproj">
<Name>InstallerCustomAction</Name>
<Project>{81128cc3-071e-4926-8a8c-1b9ac52272d6}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\OpenBots.Server.Web\OpenBots.Server.Web.csproj">
<Name>OpenBots.Server.Web</Name>
<Project>{9ca5640a-4894-497f-b89e-1c28bcee22cf}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<Target Name="BeforeBuild">
<!-- Clean previous build folder -->
<Exec Command="rd /s /q ..\OpenBots.Server.Web\bin\$(Configuration)\netcoreapp3.1\win-$(Platform)" />
<!-- Publish dotnet core app -->
<Exec Command="dotnet publish ..\OpenBots.Server.Web\OpenBots.Server.Web.csproj -c $(Configuration) -r win-$(Platform)" />
<!-- Get assembly version -->
<GetAssemblyIdentity AssemblyFiles="..\OpenBots.Server.Web\bin\$(Configuration)\netcoreapp3.1\win-$(Platform)\OpenBots.Server.Web.dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<!-- Define some variables we need -->
<PropertyGroup>
<DefineConstants>BuildVersion=%(AssemblyVersion.Version);BasePath=..\OpenBots.Server.Web\bin\$(Configuration)\netcoreapp3.1\win-$(Platform)\publish</DefineConstants>
</PropertyGroup>
<!-- Harvest file components from publish folder -->
<HeatDirectory OutputFile="ComponentsGenerated.wxs" DirectoryRefId="INSTALLFOLDER" ComponentGroupName="PublishedComponents" SuppressCom="true" Directory="..\OpenBots.Server.Web\bin\$(Configuration)\netcoreapp3.1\win-$(Platform)\publish" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.BasePath" />
</Target>
<Target Name="AfterBuild">
<!-- Get assembly version -->
<GetAssemblyIdentity AssemblyFiles="..\OpenBots.Server.Web\bin\$(Configuration)\netcoreapp3.1\win-$(Platform)\OpenBots.Server.Web.dll">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<!-- Rename and move final MSI -->
<Exec Command="if not exist Installs mkdir Installs" />
<Exec Command="move bin\$(Configuration)\$(OutputName).msi Installs\OpenBots-%(AssemblyVersion.Version)-$(Configuration)-$(Platform).msi" />
</Target>
</Project>
Produxt.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Give product a unique ID per platform -->
<?if $(var.Platform)=x64 ?>
<?define ProductCode = "{51741540-BF67-4925-8624-6EF3859DD7E4}" ?>
<?else?>
<?define ProductCode = "{097B9DA2-EA62-4990-9012-B58AFB785634}" ?>
<?endif?>
<!-- Fixed upgrade Id -->
<?define UpgradeCode = "{A0BCAB0C-23E8-414F-B9AA-D7B7304CE503}" ?>
<?define BuildVersion = 1.0.0.0 ?>
<Product Id="$(var.ProductCode)"
Name="!(loc.ProductName_$(var.Platform))"
Language="!(loc.Language)"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Company)"
UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="$(var.Platform)"
Manufacturer="!(loc.Company)"
Languages="!(loc.Language)"
/>
<!-- Option 1 -->
<CustomAction Id="ConfigureDatabaseValues" BinaryKey="CustomActionBinary" DllEntry="ConfigureDatabaseValues"/>
<Binary Id="CustomActionBinary" SourceFile="$(var.InstallerCustomAction.TargetDir)$(var.InstallerCustomAction.TargetName).CA.dll" />
<InstallExecuteSequence>
<Custom Action="ConfigureDatabaseValues" Before="InstallFinalize"/>
</InstallExecuteSequence>
<!-- Option 2 -->
<!--<CustomAction Id="ConfigureDatabaseValues" BinaryKey="CustomActionBinary" DllEntry="ConfigureDatabaseValues" Execute="immediate" />
<Binary Id="CustomActionBinary" SourceFile="$(var.InstallerCustomAction.TargetDir)$(var.InstallerCustomAction.TargetName).CA.dll" />
<InstallExecuteSequence>
<Custom Action='ConfigureDatabaseValues' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>-->
<!-- Downgrade error message -->
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" />
<!-- Include .cab file into .msi file -->
<MediaTemplate
EmbedCab="yes"
/>
<!-- Define main app icon -->
<Icon Id="icon.ico" SourceFile="$(var.OpenBots.Server.Web.ProjectDir)\ClientApp\src\openBotsfavicon.ico" />
<!-- Use the icon.ico icon for this installer (shows up in Add/Remove programs) -->
<Property Id="ARPPRODUCTICON">icon.ico</Property>
<!-- Help/Support website (shows in the Add/Remove programs) -->
<Property Id="ARPURLINFOABOUT">http://www.accelirate.com</Property>
<!-- Create a basic UI for the installer -->
<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<UIRef Id="WixUI_ErrorProgressText" />
<DialogRef Id="DatabaseConfigDialog" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="DatabaseConfigDialog" Order="3">LicenseAccepted = "1"</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="DatabaseConfigDialog">1</Publish>
</UI>
<!-- Change the installer UI background images -->
<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\Assets\License.rtf" />
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Assets\Background.bmp" />
<WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Assets\Banner.bmp" />
<!-- Define components, shortcuts, files etc... for installer -->
<Feature Id="ProductFeature" Title="OpenBotInstaller" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="PublishedComponents" />
</Feature>
</Product>
</Wix>
CustomActions.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Diagnostics;
namespace InstallerCustomAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult ConfigureDatabaseValues(Session session)
{
try
{
Debugger.Launch();
session.Log("Begin Configuring database values in appsettings.json");
string connectionString = session["CONNECTIONSTRING"];
string databaseEngine = session["CHOICE_WIN_SQL"];
//replace the values in appsettings.json for DB Engine and connection string based on user input
string dbEngineKey = "DbOption:UseSqlServer";
var dbEngineValue = databaseEngine == "1" ? false : true;
AddOrUpdateAppSetting(dbEngineKey, dbEngineValue);
session.Log("End appsettings.json configuration");
return ActionResult.Success;
}
catch (Exception)
{
return ActionResult.Failure;
}
}
private static void AddOrUpdateAppSetting<T>(string key, T value)
{
try
{
var filePath = Path.Combine(AppContext.BaseDirectory, "appSettings.json");
string json = File.ReadAllText(filePath);
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
var sectionPath = key.Split(':')[0];
if (!string.IsNullOrEmpty(sectionPath))
{
var keyPath = key.Split(':')[1];
jsonObj[sectionPath][keyPath] = value;
}
else
{
jsonObj[sectionPath] = value; // if no sectionpath just set the value
}
string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(filePath, output);
}
catch (Exception ex)
{
throw ex;
}
}
}
}
The answer was for me to find the path from the install folder like this:
var filePaths = Directory.GetFiles(#"c:\Program Files (x86)\OpenBotServer\", "*.json");
I'm attempting to compile my code (a .net core console application) into a native .exe for win-x64 using CoreRT. I was able to follow the documentation right up until the section having to do with reflection and using an rd.xml file, which is where I am currently stuck.
My project uses Dapper as the ORM, which relies on reflection to bind objects from my database. I only have 2 different types that I am binding, so my assumption is that I need to include these types in the rd.xml.
Right now, when I try to run dotnet publish -r win-x64 -c release from the .net core cli, it finishes successfully, however at runtime, my compiled .exe throws an exception with the following snippet:
---> (Inner Exception #0) System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the
InnerException's StackTrace property. --->
EETypeRva:0x01202268(System.Reflection.MissingRuntimeArtifactException):
This object cannot be invoked because it was metadata-enabled for
browsing only:
'Dapper.SqlMapper.TypeHandlerCache<System.Data.DataTable>.SetHandler(Dapper.SqlMapper.ITypeHandler)'
For more information, please visit
http://go.microsoft.com/fwlink/?LinkID=616867
My rd.xml file looks like this:
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Type Name="Dapper.SqlMapper.TypeHandlerCache{System.Data.DataTable}">
<MethodInstantiation Name="SetHandler" Arguments="Dapper.SqlMapper.ITypeHandler" Dynamic="Required" />
</Type>
</Application>
</Directives>
I assume I need to include references to my models here which would be Foo and Bar, but the error getting thrown refers to Dapper specifically.
The rd.xml file is inside of my project directory, and is referenced in the MyProject.csproj like so:
<ItemGroup>
<EmbeddedResource Include="rd.xml" />
</ItemGroup>
I'm wondering if this problem is due to my structure (perhaps the rd.xml should be referenced in a different way), or due to the content of my rd.xml file. Has anyone dealt with this, or used CoreRT on a project that uses Dapper?
Try add this to directives:
<Assembly Name="System.Data.Common">
<Type Name="System.Data.DataTable" Dynamic="Required All"/>
</Assembly>
To compile my project successfully I had to do the following:
Include all references in the System.Data.SqlClient nuget package as project references. In this case I also included those of System.Configuration.ConfigurationManager.
From the command line publish for the required operating system: dotnet publish -r win-x64
From publishing path copy the System.Data.SqlClient.dll and sni.dll files to a fixed path: ..\SQLClient\win-x64\
In csproj file make the conditional reference to the nuget package and to published dll, in this case through the parameter MSBuild NativeCompilation.
Finally, publish with CoreRT from the command line: dotnet publish -r win-x64 / p: NativeCompilation = true
And it worked!
GetIPVersionSQLSRV.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true' OR '$(NativeCompilation)' != 'true'">
<!--System.Data.SqlClient Nuget Reference -->
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<!--System.Data.SqlClient References-->
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="System.Security.AccessControl" Version="4.5.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
<!--System.Configuration.ConfigurationManager References-->
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.5.0" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' != 'true' AND '$(NativeCompilation)'=='true'">
<!-- ILCompiler and rd.xml -->
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
<RdXmlFile Include="rd.xml" />
<!--System.Data.SqlClient published Dll Reference -->
<Reference Include="System.Data.SqlClient">
<HintPath>..\SQLClient\win-x64\System.Data.SqlClient.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Program.cs
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Net;
namespace GetIPVersionSQLSRV
{
class Program
{
private static String config = ConfigurationManager.AppSettings["texto"];
private static String cadena = ConfigurationManager.ConnectionStrings["default"].ConnectionString;
static void Main(string[] args)
{
Console.WriteLine("Hello World! " + config);
using(SqlConnection conn = new SqlConnection(cadena))
{
conn.Open();
using (SqlCommand comm = new SqlCommand("SELECT ##VERSION;", conn))
Console.WriteLine(comm.ExecuteScalar());
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(#"http://api.ipify.org?format=json");
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
using (Stream strm = res.GetResponseStream())
using (StreamReader read = new StreamReader(strm))
Console.WriteLine(read.ReadToEnd());
req = null;
Console.ReadKey(false);
}
}
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="texto" value="CONFIG2"/>
</appSettings>
<connectionStrings>
<add name="default" connectionString="User ID=user;PWD=p455w0rd;Initial Catalog=master;Data Source=localhost"/>
</connectionStrings>
</configuration>
rd.xml
<Directives>
<Application>
<Assembly Name="System.Configuration.ConfigurationManager">
<Type Name="System.Configuration.ClientConfigurationHost" Dynamic="Required All"/>
<Type Name="System.Configuration.AppSettingsSection" Dynamic="Required All"/>
</Assembly>
</Application>
</Directives>
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<add key="dotnet-core"
value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json"/>
<add key="nuget.org"
value="https://api.nuget.org/v3/index.json" protocolVersion="3"/>
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
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 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.
I am trying to create a installer for MVC4 application using Wix. I found an example that shows how to create an installer for a MVC4 Application at this link
But when I try to build the Wix Setup Project, it gives me errors like below
Error 16 Unresolved reference to symbol 'WixComponentGroup:MyWebWebComponents'
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 15
1 DemoWebsite.Setup
Error 17 Unresolved reference to symbol 'WixComponentGroup:DemoWebsiteIssConfiguration'
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 16
1 DemoWebsite.Setup`
I tried adding WixUIExtension as a reference but it doesn't work.
This is the Product.wxs. And feature node's children nodes causes this error
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}" Name="Demo website setup" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="9279b740-8419-45c4-9538-6a45f8e949c7">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="DemoWebsite.cab" EmbedCab="yes" />
<Property Id="DB_USER" Value="sa"/>
<Property Id="DB_PASSWORD" Value="sa"/>
<Property Id="DB_SERVER" Value="LOCAL"/>
<Property Id="DB_DATABASE" Value="DemoWebsite"/>
<Feature Id="ProductFeature" Title="DemoWebsite.Setup" Level="1">
<ComponentGroupRef Id="MyWebWebComponents" />
<ComponentGroupRef Id="DemoWebsiteIssConfiguration" />
</Feature>
<!-- Specify UI -->
<UIRef Id="MyUI" />
<Property Id="WIXUI_INSTALLDIR" Value="INETPUB" />
</Product>
<Fragment>
<!-- Will default to C:\ if that is the main disk-->
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- Will reference to C:\inetpub-->
<Directory Id="INETPUB" Name="Inetpub">
<!-- Will reference to c:\Inetpub\Demowebsite-->
<Directory Id="INSTALLFOLDER" Name="DemoWebsite">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
What am I doing wrong? I know its very specific for SO but I cannot find any solution on the web.
I am using VS 2012- Wix 4.0
The error message says it all: it expects a ComponentGroup-tag containing your components (containing e.g. files or registry keys). If you take a look at the example project that you linked in your question, the <ComponentGroupRef Id="DemoWebsiteIssConfiguration" />-element references a ComponentGroup with the name DemoWebsiteIssConfiguration. You can find this in the file DemoWebsite.Setup\IISConfiguration.wxs:
<ComponentGroup Id="DemoWebsiteIssConfiguration">
<ComponentRef Id="InstallWebsite" />
<ComponentRef Id="DemoWebsiteAppPool" />
</ComponentGroup>
It is a ComponentGroup which contains two components or, in this case, references to two components. These components are defined above the ComponentGroup-element in the same file.
Regarding the other ComponentGroupRef with the id MyWebComponents: The referenced ComponentGroup is created dynamically during the build. You can take a look at the file DemoWebsite.Setup\setup.build. This file is a MSBuild-file used to build the setup. It contains a target named Harvest that invokes heat, another tool in the WiX Toolset package. heat will parse e.g. a directory and gather all the files contained within and put them in a ComponentGroup that you can reference in your source file. I.e. you define a reference to a ComponentGroup and then you can create the content of this dynamically. This way you don't have to bother if a file is added to or removed from the project, as heat will gather them dynamically.
<Target Name="Harvest">
<!-- Harvest all content of published result -->
<Exec
Command='$(WixPath)heat dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
ContinueOnError="false"
WorkingDirectory="." />
</Target>
The name of the dynamically created ComponentGroup is defined with the parameter -cg. you can invoke heat with the parameter -? for a short description of the possible parameters.