To update MSI property with C#,
Added reference for Microsoft.Deployment.WindowsInstaller.dll
The PropertyTable not include default value is null Propery, we can not update the value, if not in property table, we could insert the property.
using Microsoft.Deployment.WindowsInstaller;
bool isProertyExits = false ;
using (Database msi = new Database(msiFileName, DatabaseOpenMode.Transact))
{
using (var view = msi.OpenView(msi.Tables["Property"].SqlSelectString))
{
view.Execute();
Record record = view.Fetch();
while (record != null)
{
if (record.GetString(1) == ProertyName)
{
record.SetString("Value", ProertyValue);
view.Modify(ViewModifyMode.Assign, record);
msi.Commit();
isProertyExits = true;
}
record = view.Fetch();
}
}
//If not find
if (!isProertyExits) {
using (var view = msi.OpenView(msi.Tables["Property"].SqlInsertString))
{
foreach (var item in properties)
{
Record missingRecord = msi.CreateRecord(2);
missingRecord.SetString(1, ProertyName);
missingRecord.SetString(2, ProertyValue);
view.Execute(missingRecord);
msi.Commit();
}
}
}
}
Tuesday, July 11, 2017
Tuesday, June 20, 2017
wix support localization with .wixproj
1: your .wixproj files include the .wxl file
<ItemGroup>
<EmbeddedResource Include="en_us.wxl" />
<EmbeddedResource Include="zh_cn.wxl" />
</ItemGroup>
2: .wxl file look like:
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="WelcomeDlgDescription">This Setup Wizard will install [ProductName] [MajorVersion].[MinorVersion] on your computer. Click Next to continue or Cancel to exit.</String>
</WixLocalization>
http://wixtoolset.org/documentation/manual/v3/wixui/wixui_localization.html
Table of culture codes.
| Language | Location | Culture code | WXL file |
| Arabic | Saudi Arabia | ar-SA | WixUI_ar-SA.wxl |
| Bulgarian | Bulgaria | bg-BG | WixUI_bg-BG.wxl |
| Catalan | Spain | ca-ES | WixUI_ca-ES.wxl |
| Croatian | Croatia | hr-HR | WixUI_hr-HR.wxl |
| Czech | Czech Republic | cs-CZ | WixUI_cs-CZ.wxl |
| Danish | Denmark | da-DK | WixUI_da-DK.wxl |
| Dutch | Netherlands | nl-NL | WixUI_nl-NL.wxl |
| English | United States | en-US | WixUI_en-US.wxl |
| Estonian | Estonia | et-EE | WixUI_et-EE.wxl |
| Finnish | Finland | fi-FI | WixUI_fi-FI.wxl |
| French | France | fr-FR | WixUI_fr-FR.wxl |
| German | Germany | de-DE | WixUI_de-DE.wxl |
| Greek | Greece | el-GR | WixUI_el-GR.wxl |
| Hebrew | Israel | he-IL | WixUI_he-IL.wxl |
| Hindi | India | hi-IN | WixUI_hi-IN.wxl |
| Hungarian | Hungary | hu-HU | WixUI_hu-HU.wxl |
| Italian | Italy | it-IT | WixUI_it-IT.wxl |
| Japanese | Japan | ja-JP | WixUI_ja-JP.wxl |
| Kazakh | Kazakhstan | kk-KZ | WixUI_kk-KZ.wxl |
| Korean | Korea | ko-KR | WixUI_ko-KR.wxl |
| Latvian | Latvia | lv-LV | WixUI_lv-LV.wxl |
| Lithuanian | Lithuania | lt-LT | WixUI_lt-LT.wxl |
| Norwegian (Bokmål) | Norway | nb-NO | WixUI_nb-NO.wxl |
| Polish | Poland | pl-PL | WixUI_pl-PL.wxl |
| Portuguese | Brazil | pt-BR | WixUI_pt-BR.wxl |
| Portuguese | Portugal | pt-PT | WixUI_pt-PT.wxl |
| Romanian | Romania | ro-RO | WixUI_ro-RO.wxl |
| Russian | Russia | ru-RU | WixUI_ru-RU.wxl |
| Serbian (Latin) | Serbia and Montenegro | sr-Latn-CS | WixUI_sr-Latn-CS.wxl |
| Simplified Chinese | China | zh-CN | WixUI_zh-CN.wxl |
| Slovak | Slovak Republic | sk-SK | WixUI_sk-SK.wxl |
| Slovenian | Solvenia | sl-SI | WixUI_sl_SI.wxl |
| Spanish | Spain | es-ES | WixUI_es-ES.wxl |
| Swedish | Sweden | sv-SE | WixUI_sv-SE.wxl |
| Thai | Thailand | th-TH | WixUI_th-TH.wxl |
| Traditional Chinese | Hong Kong SAR | zh-HK | WixUI_zh-HK.wxl |
| Traditional Chinese | Taiwan | zh-TW | WixUI_zh-TW.wxl |
| Turkish | Turkey | tr-TR | WixUI_tr-TR.wxl |
| Ukrainian | Ukraine | uk-UA | WixUI_uk-UA.wxl |
embedding dlls into exe .net C#
https://stackoverflow.com/questions/6920920/embedding-dlls-into-exe-in-in-visual-c-sharp-2010
1: visual studio project include the dlls Build Action as "Embedded Resource"
2: in program.cs file ,
using System.Reflection;
using System.IO;
3: in main() function
//Load embedded resources dll to CurrentDomain.
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
String dllName = new AssemblyName(args.Name).Name + ".dll";
var assem = Assembly.GetExecutingAssembly();
String resourceName = assem.GetManifestResourceNames().FirstOrDefault(rn => rn.EndsWith(dllName));
if (resourceName == null) return null;
using (var stream = assem.GetManifestResourceStream(resourceName))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
1: visual studio project include the dlls Build Action as "Embedded Resource"
2: in program.cs file ,
using System.Reflection;
using System.IO;
3: in main() function
//Load embedded resources dll to CurrentDomain.
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
String dllName = new AssemblyName(args.Name).Name + ".dll";
var assem = Assembly.GetExecutingAssembly();
String resourceName = assem.GetManifestResourceNames().FirstOrDefault(rn => rn.EndsWith(dllName));
if (resourceName == null) return null;
using (var stream = assem.GetManifestResourceStream(resourceName))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
Subscribe to:
Posts (Atom)