最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - wix - The Component element contains an unexpected child element 'TaskScheduler' - Stack Overflow

programmeradmin5浏览0评论

This is my MSIPackage.wxs

<Wix xmlns=";
     xmlns:util=";>
    <Package Name="Boton de Panico" Language="1033" Version="1.0.0.0" Manufacturer="mrtn" UpgradeCode="7cea14c0-6506-4823-828d-940ce4e10ce5" InstallerVersion="200">
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <Feature Id="ProductFeature" Title="AppBotonPanicoSetup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
            
            <!--Comment out to add component reference to your featur  <ComponentRef Id="StartMenuShortcutComponent" /> -->
        </Feature>
</Package>

<Fragment>
    <StandardDirectory Id="ProgramFiles64Folder">
        <Directory Id="INSTALLFOLDER" Name="Boton de Panico" />
    </StandardDirectory>
        <!--1. Comment out to add your application shortcut to Windows start 
            <Directory Id="ProgramMenuFolder">
                <Directory Id="ApplicationProgramsFolder" Name="Boton de Panico">
                    <Component Id="StartMenuShortcutComponent" Guid="8D3D3D3D-3D3D-3D3D-3D3D-3D3D3D3D3D3D">
                        <Shortcut
                            Id="StartMenuShortcut"
                            Name="Boton de Panico"
                            Description="Boton de Panico"
                            Target="[INSTALLFOLDER]AppBotonPanico.exe"
                            WorkingDirectory="INSTALLFOLDER">
                            <Icon Id="TrayIcon3.ico" SourceFile="$(var.AppBotonPanico.TargetDir)TrayIcon3.ico" />
                        </Shortcut> -->
                <!-- Remove the Start Menu folder on uninstall 
                        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" /> -->
                        <!-- Comment out to add an icon on your application 
                        <RegistryValue Root="HKCU" Key="SOFTWARE\BotonPanico" Name="StartMenuInstalled" Type="integer" Value="1" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory> -->
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <Files Directory="INSTALLFOLDER" Include="$(var.AppBotonPanico.TargetDir)/**"/>
        
        <Component Id="AppShortcut" Guid="7D3D3D3D-3D3D-3D3D-3D3D-3D3D3D3D3D3D">
            <Shortcut Id="AppShortcut" Name="AppBotonPanico" Description="Boton de Panico" Target="[INSTALLFOLDER]AppBotonPanico.exe" WorkingDirectory="INSTALLFOLDER">
        <!--2. Comment out to add an icon on your application <Icon Id="trayIconInstall.ico" SourceFile="$(var.AppBotonPanico.TargetDir)TrayIcon3.ico"></Icon>-->
            </Shortcut>
            <RemoveFolder Id="INSTALLFOLDER" On="uninstall" />
        </Component>
        
        <Component Id="AutoStart">
            <RegistryKey Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Run">
                <RegistryValue Type="string" Name="Boton de Panico" Value="[INSTALLFOLDER]AppBotonPanico.lnk" />
            </RegistryKey>
        </Component>

        <Component Id="ScheduledTask" Guid="4e568929-01a3-419d-abe1-c2bf82c37670">
            <File Id="AppBotonPanico.exe" Name="AppBotonPanico.exe" KeyPath="yes" />
            <util:TaskScheduler
                Id="StartupTask"
                Name="BotonDePanicoStartup"
                Description="Runs Boton de Panico at system startup."
                Executable="[INSTALLFOLDER]AppBotonPanico.exe"
                Arguments=""
                UserId="SYSTEM"
                LogonType="ServiceAccount"
                AtStartup="yes"
                DisallowStartIfOnBatteries="no"
                StopIfGoingOnBatteries="no"
                ExecutionTimeLimit="PT0S" />
        </Component>

    </ComponentGroup>
</Fragment>

This is my .wixproj file.

<Project Sdk="WixToolset.Sdk/5.0.2">
  <PropertyGroup>
    <ProductVersion>1.0.0</ProductVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <DefineConstants>Release</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
      <PackageReference Include="WixToolset.Util.wixext" Version="5.0.2" />
      <ProjectReference Include="..\AppBotonPanico\AppBotonPanico.csproj" />
  </ItemGroup>
</Project>

I can't really understand what's the matter here. I have installed the Wix toolset here in this path: C:\Program Files (x86)\WiX Toolset v3.14 The extension of the wixproj points out to a certain extension which is the one responsible for handling the util schema for Wix v.4

D:\Users\xxxxxxxx\.nuget\packages\wixtoolset.util.wixext\5.0.2

I tried even removing the Sdk="WixToolset.Sdk/5.0.2" and pointing out the PackageReference version to For some reason, I have two versions of Wixtoolset installed on my machine. One is 4.0.0 and the other one is 5.0.2

It is believed that this schema has to be mentioned xmlns:util="; on top of your MSIPackage.wxs so that the xml can identify and read this line of code here and register the task on auto-play whenever Windows starts(no user login):

<util:TaskScheduler
                Id="StartupTask"
                Name="BotonDePanicoStartup"
                Description="Runs Boton de Panico at system startup."
                Executable="[INSTALLFOLDER]AppBotonPanico.exe"
                Arguments=""
                UserId="SYSTEM"
                LogonType="ServiceAccount"
                AtStartup="yes"
                DisallowStartIfOnBatteries="no"
                StopIfGoingOnBatteries="no"
                ExecutionTimeLimit="PT0S" />

If anyone has encountered the same problem here, it would be highly appreciating to mention any kind of solutions. Thanks you!

发布评论

评论列表(0)

  1. 暂无评论