Neyoh
Neyoh

Reputation: 633

WiX error build target

I'm trying to create my MSI setup with WiX and MSBuild command which deploy my img.png into a repertory and i have this error :

"MSB4019: project imported "C:\Program Files\MSBuild\Microsoft\WiX\v[[Version.M ajor]].x\Wix.targets" was not found. " Make sure that path of declaration are correct

In this line :

<Import Project="$(WixTargetPath)" />

Here my 2 files (test.wixproj and test.wxs) :

test.wixproj

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
                <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
                <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
                <ProductVersion>3.0</ProductVersion>
                <ProjectGuid>{}</ProjectGuid>
                <SchemaVersion>2.0</SchemaVersion>
                <OutputName>WixProject1</OutputName>
                <OutputType>Package</OutputType>
                <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v[[Version.Major]].x\Wix.targets</WixTargetsPath>
        </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>
        <ItemGroup>
                <Compile Include="C:\testW2.wxs" />
        </ItemGroup>
        <Import Project="$(WixTargetsPath)" />
    </Project>

test.wxs

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" UpgradeCode="" Version="1.0.0.0" Language="1033" Name="My Application Name" Manufacturer="My Manufacturer Name">
        <Package InstallerVersion="300" Compressed="yes"/>
        <Media Id="1" Cabinet="myapplication.cab" EmbedCab="yes" />


        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="APPLICATIONROOTDIRECTORY" Name="Application test"/>
            </Directory>
        </Directory>


        <DirectoryRef Id="APPLICATIONROOTDIRECTORY">
            <Component Id="myimg" Guid="">
                <File Id="myimg" Source="C:\img.png" KeyPath="yes" Checksum="yes"/>
            </Component>

        </DirectoryRef>


        <Feature Id="MainApplication" Title="Main Application" Level="1">
            <ComponentRef Id="myimg" />
        </Feature>
    </Product>
</Wix>

I don't unstandand where is the problem and i don't find an easy tutorial on WiX without VisualStudio.

Can you help me ?

Upvotes: 0

Views: 5547

Answers (1)

bradfordrg
bradfordrg

Reputation: 1903

There are two problems with your project file:

  1. The <WixTargetPath ...> line [[MajorVersion]] should be replaced with '3',
  2. The <Compile...> line should to refer to the correct file 'Test.wxs'.

Try this project file:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
            <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
            <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
            <ProductVersion>3.0</ProductVersion>
            <ProjectGuid>{}</ProjectGuid>
            <SchemaVersion>2.0</SchemaVersion>
            <OutputName>WixProject1</OutputName>
            <OutputType>Package</OutputType>
            <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    </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>
    <ItemGroup>
            <Compile Include="test.wxs" />
    </ItemGroup>
    <Import Project="$(WixTargetsPath)" />
</Project>

You also need to make sure test.wxs has a GUID in the UpgradeCode attribute.

Upvotes: 1

Related Questions