WiX to install EventSource - c#

I created my event source based on this example. My event source looks like this:
[EventSource(Name = "Samples-EventSourceDemos-EventLog")]
public sealed class MinimalEventSource : EventSource
{
public static MinimalEventSource Log = new MinimalEventSource();
[Event(1, Message = "{0} -> {1}", Channel = EventChannel.Admin)]
public void Load(long baseAddress, string imageName)
{
WriteEvent(1, baseAddress, imageName);
}
}
The example use code to simulate install/uninstall process. From some other SO questions, I saw another example of installing event source using event message file.
But it is missing some good examples how to install/register the EventSource that defined by manifests. I am investigating using CustomAction to do something like:
wevtutil.exe im <EtwManifestManFile> /rf:"EtwManifestDllFile" /mf:"EtwManifestDllFile"
but wondering if you have any suggestions?

Figured out after some search. In the WixUtilExtension, there is build-in support. After referencing it and adding namespace, it is pretty easy.
Here are the changes in the Product.wxs:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
...
<Component Id="etwManifest.dll">
<File Id="etwManifest.dll" KeyPath="yes"
Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" />
</Component>
<Component Id="etwManifest.man">
<File Id="etwManifest.man" KeyPath="yes"
Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.man">
<util:EventManifest MessageFile="[etwManifest.dll]" ResourceFile="[etwManifest.dll]"></util:EventManifest>
</File>
</Component>
</Wix>
The only trick I had to do is reduce the length of component Id and File Id (used to match with the file names) to avoid the following error: Error 25540. There was a failure while configuring XML files.

For me, the sollutions was to add permission to both files, the .dll and the .man. (https://stackoverflow.com/a/32727624/5500092)
<util:PermissionEx User="Everyone" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" />
I also had to add the full path to correctly registrate the manifest file. When i didn't do that, the manifest file still refer to the bin/release folder of my visual studio solution.
<util:EventManifest MessageFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" ResourceFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll"/>
Code:
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="etwManifest.dll" Guid="PUT-GUID-HERE">
<File Id="etwManifest.dll" KeyPath="yes" Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" >
<util:PermissionEx User="Everyone" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" />
<util:PermissionEx User="Administrators" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
</File>
</Component>
<Component Id="etwManifest.man" Guid="PUT-GUID-HERE">
<File Id="etwManifest.man" KeyPath="yes" Source="$(var.SampleClassLibrary.TargetDir)\SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.man" >
<util:PermissionEx User="Everyone" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
<util:PermissionEx User="Administrators" ReadPermission="yes" ReadAttributes="yes" ReadExtendedAttributes="yes"/>
<util:EventManifest MessageFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll" ResourceFile="[INSTALLFOLDER]SampleClassLibrary.Samples-EventSourceDemos-EventLog.etwManifest.dll"/>
</File>
</Component>
</DirectoryRef>
Using WiX Toolset v3.10
(Please do correct me if my English is bad)

Related

Create MSI setup with WIX .CA.DLL file not found

I'm trying to build a WIX setup but it keep failing.
Error The system cannot find the file 'C:\Work\Test\CustomActionForm\bin\Debug\CustomActionForm.CA.dll'.
My product.wxs file
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject4" Language="1033" Version="1.0.0.0" Manufacturer="MSPmate" UpgradeCode="b9c48ec5-2f0a-4c74-abc6-0c98119861d4">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="SetupProject4" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<InstallExecuteSequence>
<Custom Action='CustomActionFormId' Before='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Binary Id="CustomActionBinary" SourceFile="$(var.CustomActionForm.TargetDir)$(var.CustomActionForm.TargetName).CA.dll" />
<CustomAction Id="CustomActionFormId" Impersonate="no" BinaryKey="CustomActionBinary" DllEntry="ShowLicenseInfo" Return="check" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject4" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Source="$(var.WindowsFormsApp1.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
This is my custom action.
namespace CustomActionForm
{
public class CustomAction
{
[CustomAction]
public static ActionResult ShowLicenseInfo(Session session)
{
try
{
session.Log("Custom Action beginning");
MessageBox.Show("Yo hoooooooooo");
// Do Stuff...
//if (cancel)
//{
// session.Log("Custom Action cancelled");
// return ActionResult.Failure;
//}
session.Log("Custom Action completed successfully");
return ActionResult.Success;
}
catch (SecurityException ex)
{
session.Log("Custom Action failed with following exception: " + ex.Message);
return ActionResult.Failure;
}
}
}
}
However, when I build the custom project, it build successfully but cannot even see a *.CA.dll file is generated.
What am I missing here?
Download Sample Project: Most likely there is something wrong with the compilation of that zip / win32 dll (as opposed to the
managed code dll) - please see if you can compile this project
outright - "right out of the box":
https://github.com/glytzhkof/WiXCustomActionsTesting
Causes?: There could be a simple build failure for the CA dll. There could be something wrong with your Visual Studio - maybe. Might be something completely different. Please just start testing with that sample project.
Build Output: The Visual Studio build output should look something like this:
------ Build started: Project: CustomAction1, Configuration: Debug x86 ------
Searching for custom action entry points in CustomAction1.dll
Loaded dependent assembly: C:\Program Files (x86)\WiX Toolset v3.11\SDK\Microsoft.Deployment.WindowsInstaller.dll
CustomAction1=CustomAction1!CustomAction1.CustomActions.CustomAction1
Searching for an embedded UI class in CustomAction1.dll
Modifying SfxCA.dll stub
Copying file version info from E:\Testing\CA\obj\x86\Debug\CustomAction1.dll to E:\Testing\CA\obj\x86\Debug\CustomAction1.CA.dll
Packaging files
CustomAction1.dll
Microsoft.Deployment.WindowsInstaller.dll
CustomAction1.pdb
CustomAction.config
MakeSfxCA finished: E:\Testing\CA\obj\x86\Debug\CustomAction1.CA.dll
CustomAction1 -> E:\Testing\CA\obj\x86\Debug\CustomAction1.dll
MakeSfxCA.exe: For the record, the building of the CustomAction1.CA.dll file involves zipping up the managed code dll version CustomAction1.dll and also its dependencies in a Win32 binary. The file MakeSfxCA.exe (Firegiant's documentation page) is a DTF file (Deployment Tools Foundation). More details here.
DTF.chm: There is more documentation in the DTF.chm help file located in the WiX installation directory's "doc" sub-folder (normally: "%ProgramFiles(x86)%\WiX Toolset v3.11\doc\DTF.chm") - search for MakeSfxCA.exe.

mixed-case guid error while working with WIX tool

I created a windows installer .msi file using wix tool but I'm having some errors
Errors
1. The Component/#Guid attribute's value, '47845d50-01e6-40ff-8b53-14f664bfb13a', is a mixed-case guid. All letters in a guid value should be uppercase. FileWatcherSetup in C:\Main\Src\Installer\FileWatcherSetup\Components.wxs 11
2. The component 'FileWatcher.Files' does not have an explicit key path specified. If the ordering of the elements under the Component element changes, the key path will also change. To prevent accidental changes, the key path should be set to 'yes' in one of the following locations: Component/#KeyPath, File/#KeyPath, ODBCDataSource/#KeyPath, or Registry/#KeyPath. FileWatcherSetup C:\Main\Src\Installer\FileWatcherSetup\Components.wxs 47
3. The Product/#UpgradeCode attribute's value, '11e6c23f-7a30-4651-b27a-b569765c3780', is a mixed-case guid. All letters in a guid value should be uppercase. FileWatcherSetup C:\Main\Src\Installer\FileWatcherSetup\Product.wxs 9
Anybody have any idea how to solve this. Any info or article will be helpful . Help please
UPDATE
components.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?include Defines.wxi?>
<Fragment>
<ComponentGroup Id="MenuComponents" Directory="ProductMenuFolder">
<Component Id="ProductMenuComponents" Guid="47845D50-01E6-40FF-8B53-14F664BFB13A">
<!--<Shortcut Id="UninstallPackage" Directory="ProductMenuFolder" Name="Uninstall package"
Target="[System64Folder]msiexec.exe" Arguments="/x {[ProductCode]}" Description="Uninstalls $(var.YourApplicationReference.TargetName)"/>-->
<RemoveFolder Id='ProductMenuFolder' On='uninstall' />
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]'
Type='string' Value='' KeyPath='yes' />
</Component>
</ComponentGroup>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="FileWatcher">
<File Source="$(var.FileWatcher.TargetPath)" />
<!--Register this file as a Windows service-->
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Description="Sends Incoming mainframe files to the MAID Webservice"
DisplayName="FileWatcher"
Vital="yes"
Start="auto"
ErrorControl="ignore"
Interactive="no"
Name="FileWatcher"
Account="[ACCOUNT]"
Password="[PASSWORD]">
<!--<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Description="Sends Incoming mainframe files to the MAID Webservice"
DisplayName="FileWatcher"
Vital="yes"
Start="auto"
ErrorControl="ignore"
Interactive="no"
Name="FileWatcher" >-->
<ServiceConfig Id="svcConfig" DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" OnUninstall="no" />
</ServiceInstall>
<!--Set the user to be used by the service-->
<util:User Id="ServiceUser" Name="[ACCOUNT]" Password="[PASSWORD]" CreateUser="no" LogonAsService="yes" UpdateIfExists="yes" />
<!--Added example of how to stop service automatically-->
<ServiceControl Id="ServiceControl" Stop="both" Remove="uninstall" Name="FileWatcher" Wait="yes" />
</Component>
<Component Id="FileWatcher.Files" Guid="{946A48FD-42F1-404F-A610-5A3DB388BD16}">
<!--<Component Id="MAIDFileWatcher.Files" Guid="{11E6C23F-7A30-4651-B27A-B569765C3780}">-->
<File Id="filB93E7D71690869B9CD2D0A479DB69C6C" Source="$(var.FileWatcher.TargetDir)\ExceptionHandling.dll" />
<File Id="fil487232F7A833919419AF9537A4390083" Source="$(var.FileWatcher.TargetDir)\ExceptionHandling.xml" />
<File Id="filDE3649B71309470D2D7C086E0FAABAE8" Source="$(var.FileWatcher.TargetDir)\itextsharp.dll" />
<File Id="filF73350F1AEF9ECF2621D4E63B9823029" Source="$(var.FileWatcher.TargetDir)\FileWatcher.exe.config" KeyPath='yes'/>
</Component>
</ComponentGroup>
As for the basic Windows Installer documentation:
The ProductCde documentation here says uppercase is required:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370854(v=vs.85).aspx
Component table says guids must be uppercase:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa368007(v=vs.85).aspx
and the Guid column type documentation again repeats the uppercase requirement:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa368767(v=vs.85).aspx
As PhilDW has already stated, just uppercase your GUIDs, or leave them out altogether from your components as explained here: Syntax for guids in WIX? (they will be auto-generated for you - there are some exceptions).
Also, I recommend using one file per component if your package isn't huge. This avoids all kinds of problems (for patching, upgrades, self-repair, etc...): Change my component GUID in wix? And set a key path for every component (might be done for you if there is only one file per component, I am not sure).
Obvious, but I'll add that you can create uppercase GUIDs, in Visual Studio: Tools => Create GUID => Registry Format => New Guid => Copy. Or a lot of web pages do it for you. I assume this is obvious, just throwing it in since I am writing anyway.

Wix Custom Action Implementation for Writing Installfolder in text

I have following Wix Code that is supposed to send the value of property to Custom Action Written in C#. Basically what I want is when the MSI is installed, I want to write the path of Folder where Wix installed the program in text file. I referred to this site and created code accordingly, but my Custom Action isn't working.
Following is my Wix File:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupInstallFolder" Language="1033" Version="1.0.0.0" Manufacturer="LP" UpgradeCode="9e10a7d8-4ffb-493c-8318-c44ba4bc0c4c">
<Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupInstallFolder" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupInstallFolder" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="SomeRandomEXE">
<File Source ="G:\SarVaGYa\myworkspace\LatestLpa\lpa\lpa_c\here\src\lpa\Release\lpa.exe" />
</Component>
</ComponentGroup>
<Binary Id="SetupCA2" src="G:\visual studio stuffs\SetupCAInstallFolder\SetupCAInstallFolder\bin\Release\SetupCAInstallFolder.CA.dll"/>
<CustomAction Id="INSTALLFOLDERFINDER" Execute="immediate" Property="INSTALLEDPATH" Value="[INSTALLFOLDER]" />
<InstallExecuteSequence>
<Custom Action="INSTALLFOLDERFINDER" Sequence="2"></Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>
I have also given my C# code that is supposed to get the value and write it in file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
namespace SetupCAInstallFolder
{
public class CustomActions
{
[CustomAction]
public static ActionResult InstallFolderFinder(Session session)
{
session.Log("Here is the SetupCAInstallFolder");
string path = session["INSTALLEDPATH"];
session.Log("Installed Path is " + path);
System.IO.File.WriteAllText("F:\\pathgenerated.txt", path);
//System.IO.File.WriteAllText(path + "installed.txt", "sdkasdkasdlkasdk");
return ActionResult.Success;
}
}
}
The Wix file compiles and gives MSI that doesn't get the value of INSTALLEDPATH . If I add DllEntry="InstallFolderFinder" in CustomAction tag, it fails with error The CustomAction/#DllEntry attribute cannot coexist with a previously specified attribute on this element. The CustomAction element may only have one of the following target attributes specified at a time: DllEntry, Error, ExeCommand, JScriptCall, Script, Value, or VBScriptCall
How do I pass the value of INSTALLEDPATH to C# Custom Action?
I have fixed the issue after stumbling around some more site. I have added the code in gist. The Wix File Code is here and the C# Custom action code is here . Basically I added
two Custom tags in InstallExexuteSequeunce that first loads the dllentry and the second passes the parameter to Custom Action Written in C#.
MSI is determining the paths between the actions CostInitialize and CostFinalize.
Using hardcoded sequences is very rarely to recommend, and maybe you have chosen the wrong sequence number for this.
Try:
<InstallExecuteSequence>
<Custom Action='INSTALLFOLDERFINDER' After='CostFinalize'></Custom>
</InstallExecuteSequence>
I hope you are sure, INSTALLDEDPATH is your the correct property. The MSI base property for paths is `TARGETDIR.
If it still doesn't work, try a custom action type 51 with setting a property MYDUMMY on the value of [INSTALLEDPATH]. Now you can see, if at least the value is correctly written in a standard custom action not programmed.

Windows service not working after successful install and start (using Wix Toolset 3.7)

I was looking for answers but not found one, so I'm posting this.
I have build a windows service, which I have to install on customer server. I have successfully tested it localy (installed with installutil.exe through Visual Studio cmd prompt). Now, I'm trying to do installation using Wix Toolset 3.7. The service installs and starts ok, but I don't get anything from it. It doesn't do anything, no calls to database (as it should) and nothing. It is there, it lives, but it doesn't do sqat. A bit lazy service it is.
I can not figure ot what am I doing wrong. Here is my Wix code:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="NeoSrvKrka" Language="1033" Version="1.0.0.0" Manufacturer="Neolab d.o.o." UpgradeCode="04f2a5be-92e1-4c53-8e45-7ae2740a9098">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Manufacturer="Neolab d.o.o." />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="NeoSrvKrka" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="NeoSrvKrka" />
</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 Id="NeoSrvExe" Name="SalusWindowsService.exe" Source="..\SalusWindowsService\bin\Debug\SalusWindowsService.exe" Vital="yes" KeyPath="yes"></File>
<File Id="NeoSrvExeConfig" Name="SalusWindowsService.exe.config" Source="..\SalusWindowsService\bin\Debug\SalusWindowsService.exe.config" Vital="yes" KeyPath="no"></File>
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="SalusKrkaService"
DisplayName="Salus Krka Service"
Description="Windows service za prenos narocil iz Salusa v Krko"
Start="auto"
Account="LocalSystem"
ErrorControl="ignore"
Interactive="no"
>
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="SalusKrkaService" Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
In my app I have also created ProjectInstaller file and all the magic around it (maybe I shoudln't use this with wix?). Oh, I'm using Visual Studio 2012, .NET 4.5, c#, windows 7 (will be windows server 2012 in production).
I am adding some code that should be executing:
namespace SalusWindowsService
{
public partial class Krka : ServiceBase
{
public Krka()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
try
{
Timer timer = new Timer();
timer.Interval = 3000; //5 minut
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer.Enabled = true;
GC.KeepAlive(timer);
}
catch (Exception exc)
{
//NeoException.Handle(exc);
}
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{ //do something, but it is not doing anything...}}}
I put some breakpoints in the code and even in the Main function of service (which just initializes base class), but I never get there.
(Answered by the OP in the question. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
It turned out i wasn't adding enough dlls to installation.
So, nothing wrong with Wix or the code. As a reminder for anyone out there doing the same mistake. You have to add ALL dll-s under wix . So, if you have multiple ddl-s in your Debug/bin folder of application, you have to add all (or at least many) of them into . That means, many tags inside one tag. Be careful, only one tag has KeyPath attribute set to "yes".

Removing attributes from elements

I will start off with the code...
private static void File()
{
wixFile = XDocument.Load(filePath);
var fileElements = from file in wixFile.Descendants(GetWixNamespace() + "File")
select file;
foreach (var file in fileElements)
{
if(file.Attributes("Name").Any())
file.Attribute("Name").Remove();
}
wixFile.Save(filePath);
}
I actually check for quite a few attributes in the list and remove or correct them, but just to keep it short I took everything out except for one example of what I was doing. The problem that I am having is that this code is not removing the Name attribute from anything like I would expect it. When I put a break point in and watch it the "file" is getting updated as expected, but the changes are not going over to the wixFile when I save (or during the editing either). I am not entirely sure what I am missing here so any help would be greatly appreciated.
EDIT:
Here is a snippet of the code that is being changed:
<?define ApplicationPath=\\dwdata\develope\DocuWare\DW5\Mast_dsk\?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Directory Id="DATADIR" Name="data">
<Directory Id="mysql" Name="mysql">
<Component Id="procs_priv.MYI" Guid="{1148181A-4818-434F-B2D1-E4B417586168}">
<File Id="procs_priv.MYI" Name="procs_priv.MYI" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.MYI" />
</Component>
<Component Id="procs_priv.MYD" Guid="{A6688F48-71AF-4242-B6D0-CA69452A01B4}">
<File Id="procs_priv.MYD" Name="procs_priv.MYD" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.MYD" />
</Component>
<Component Id="procs_priv.frm" Guid="{3025C26C-8DFF-43D4-A62A-79E78D2D807D}">
<File Id="procs_priv.frm" Name="procs_priv.frm" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\procs_priv.frm" />
</Component>
<Component Id="proc.MYI" Guid="{FD4AA2E1-E059-4549-AE61-222878185A0A}">
<File Id="proc.MYI" Name="proc.MYI" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.MYI" />
</Component>
<Component Id="proc.MYD" Guid="{12EE6EE8-AC44-4601-84C5-14B27CF9A3E6}">
<File Id="proc.MYD" Name="proc.MYD" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.MYD" />
</Component>
<Component Id="proc.frm" Guid="{8A6F2928-5484-4B55-B75F-8475C684A091}">
<File Id="proc.frm" Name="proc.frm" KeyPath="yes" Source="$(var.ApplicationPath)Common\MySql\Server\data\mysql\proc.frm" />
</Component>
</Directory>
</Directory>
</Wix>
I am getting the exact same thing back as well. What I am trying to do is remove the "Name" attribute, but it just isn't working for whatever reason. The GetWiXNamespace() method returns the same namespace that is listed in the wix element as an XNamespace.
I'm going to read between the lines here and guess you are converting from an old version of WiX ( say 2.0 ) that required a File#Name attribute to a version ( say 3.0-3.6 ) that can infer this attribute and doesn't require it.
Here's some code that I just whipped up that I know works assuming the source xml is WiX 3.x. I'm not sure what is wrong with your code but perhaps the method that returns the namespace hasn't accounted for the url change.
XNamespace ns = "http://schemas.microsoft.com/wix/2006/wi";
var doc = XDocument.Load(#"C:\before.wxs");
var elements = from element in doc.Descendants( ns + "File")
where element.Attribute("Name") != null
select element;
foreach (var element in elements)
{
element.Attribute("Name").Remove();
}
doc.Save(#"C:\after.wxs");
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define SourceDir="."?>
<Module Id="YourModuleHere" Language="1033" Version="1.0.0.0">
<Package Id="31c7722e-c2a0-4328-92a2-eacd443c10a9" Manufacturer="YourCompanyHere" InstallerVersion="200" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="MergeRedirectFolder">
<Component Id="owc7CEF9B0C53324FC23404D2AAAB5D12B8" Guid="6898e947-fa51-8efb-bda4-2e256dea8ed1">
<File Id="owf7CEF9B0C53324FC23404D2AAAB5D12B8" Name="bfsvc.exe" Source="$(var.SourceDir)\Windows\bfsvc.exe" KeyPath="yes" />
</Component>
<Component Id="owc8C6EA26177072C0006EEF8265FEF72A4" Guid="91737806-0b20-24ad-9653-cca05b5778fb">
<File Id="owf8C6EA26177072C0006EEF8265FEF72A4" Name="explorer.exe" Source="$(var.SourceDir)\Windows\explorer.exe" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Module>
</Wix>

Categories