Copy files from the NuGet package to the destination project when installing the nuget package - nuget

I'm working on the packaging part of module development and I was able to successfully create the package and install it on the destination site.
But I have an issue with copying files to the module folder in the destination project when installing. It creates some references for folders, not real folders. There are no physical files created in the modules folder in the destination project. But we noticed that it was created in the global NuGet folder on my computer (C:\Users<User>.nuget\packages).
Check the following Screenshots
I'm using Package.nuspec file and .targets file as follows:
Package.nuspec
<?xml version="1.0"?>
<package >
<metadata xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<id>QBankModule6</id>
<version>6.0.74</version>
<title>QBank Module 6</title>
<authors>QBNK AB</authors>
<owners />
<iconUrl>http://nuget.episerver.com/Framework/Styles/images/icons/default_package_icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>QBank Module is a module for media support. The module includes a QBank tool for EPiServer.Cms.TinyMce 2.1.1.0 or higher versions and media references. IMPORTANT: After first install, go to Admin mode to initiate QBank.</description>
<tags>EPiServerModulePackage ThirdPartyAddOn Media Images DAM Mediabank Streaming QBank</tags>
<dependencies>
<group targetFramework="net5.0">
<dependency id="EPiServer.CMS.Core" version="[12.0.3, 13)" />
<dependency id="RestSharp" version="106.11.7" />
<dependency id="log4net" version="[2.0.0, 2.9999)" />
<dependency id="HtmlAgilityPack" version="[1.8.4.0, 1.8.4.9)" />
</group>
</dependencies>
<contentFiles>
<files include="any/any/modules/_protected/QBankModule/ClientResources/Scripts/Editors/QBankMediaPicker.js" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/ClientResources/Scripts/qbank-connector.js" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/ClientResources/Scripts/QBankResponsiveLight-1.0.js" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/ClientResources/Scripts/jquery.js" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/ClientResources/Styles/qbankplugin.css" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/TinyPlugin/editor_plugin.js" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/module.config" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/lang/QbankModule_lang.xml" buildAction="None" copyToOutput="true"/>
<files include="any/any/modules/_protected/QBankModule/QBankModule.zip" buildAction="None" copyToOutput="true"/>
<files include="any/any/web.config.install.xdt" buildAction="None" copyToOutput="true"/>
<files include="any/any/web.config.uninstall.xdt" buildAction="None" copyToOutput="true"/>
<files include="any/any/QbankApi.dll" buildAction="Compile" copyToOutput="true"/>
<files include="any/any/Qbank.Connector.Core.dll" buildAction="Compile" copyToOutput="true"/>
<files include="any/any/Qbank.Connector.EpiCore.dll" buildAction="Compile" copyToOutput="true"/>
<files include="any/any/Qbank.Connector.EpiCore11.dll" buildAction="Compile" copyToOutput="true"/>
<files include="any/any/Qbank.Connector.EpiServerModule5.dll" buildAction="Compile" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="Qbank.Connector.EpiServerModule5/build/QBankModule6.targets" target="lib/net5.0" />
<file src="Qbank.Connector.EpiServerModule5/bin/net5.0/QbankApi.dll" target="lib/net5.0" />
<file src="Qbank.Connector.EpiServerModule5/bin/net5.0/Qbank.Connector.Core.dll" target="lib/net5.0" />
<file src="Qbank.Connector.EpiServerModule5/bin/net5.0/Qbank.Connector.EpiCore.dll" target="lib/net5.0" />
<file src="Qbank.Connector.EpiServerModule5/bin/net5.0/Qbank.Connector.EpiCore11.dll" target="lib/net5.0" />
<file src="Qbank.Connector.EpiServerModule5/bin/net5.0/Qbank.Connector.EpiServerModule5.dll" target="lib/net5.0" />
<!--<file src="Qbank.Connector.EpiServerModule5/ClientResources/Images/qbank-loader.gif" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Images/qbank-loader.gif" />-->
<!--<file src="Qbank.Connector.EpiServerModule5/ClientResources/Images/qbankadd.png" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Images/qbankadd.png" />-->
<file src="Qbank.Connector.EpiServerModule5/ClientResources/Scripts/Editors/QBankMediaPicker.js" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Scripts/Editors/QBankMediaPicker.js" />
<file src="Qbank.Connector.EpiServerModule5/ClientResources/Scripts/qbank-connector.js" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Scripts/qbank-connector.js" />
<file src="Qbank.Connector.EpiServerModule5/ClientResources/Scripts/QBankResponsiveLight-1.0.js" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Scripts/QBankResponsiveLight-1.0.js" />
<file src="Qbank.Connector.EpiServerModule5/ClientResources/Scripts/jquery.js" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Scripts/jquery.js" />
<file src="Qbank.Connector.EpiServerModule5/ClientResources/Styles/qbankplugin.css" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Styles/qbankplugin.css" />
<file src="Qbank.Connector.EpiServerModule5/TinyPlugin/editor_plugin.js" target="contentFiles/any/any/modules/_protected/QBankModule/TinyPlugin/editor_plugin.js" />
<!--<file src="Qbank.Connector.EpiServerModule5/TinyPlugin/Img/qbank.png" target="contentFiles/any/any/modules/_protected/QBankModule/TinyPlugin/Img/qbank.png" />-->
<file src="Qbank.Connector.EpiServerModule5/module.config" target="contentFiles/any/any/modules/_protected/QBankModule/module.config" />
<file src="Qbank.Connector.EpiServerModule5/Lang/QbankModule_lang.xml" target="contentFiles/any/any/modules/_protected/QBankModule/lang/QbankModule_lang.xml" />
<file src="Qbank.Connector.EpiServerModule5/web.config.install.xdt" target="contentFiles/any/any"/>
<file src="Qbank.Connector.EpiServerModule5/web.config.uninstall.xdt" target="contentFiles/any/any"/>
<!--CDN Solution-->
<!--<file src="Qbank.Connector.EpiServerModule5/ClientResources/Images/qbankaudio.png" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Images/qbankaudio.png" />-->
<!--<file src="Qbank.Connector.EpiServerModule5/ClientResources/Images/qbankdocument.png" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Images/qbankdocument.png" />-->
<!--<file src="Qbank.Connector.EpiServerModule5/ClientResources/Images/qbankvideo.png" target="contentFiles/any/any/modules/_protected/QBankModule/ClientResources/Images/qbankvideo.png" />-->
<!--<file src="Qbank.Connector.EpiServerModule5/build/QBankModule6.props" target="build" />-->
<file src="Qbank.Connector.EpiServerModule5/build/QBankModule6.targets" target="build" />
<file src="Qbank.Connector.EpiServerModule5/QbankModule.zip" target="contentFiles/any/any/modules/_protected/QBankModule/QBankModule.zip" />
</files>
</package>
QBankModule6.targets
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<SourceScripts Include="$(MSBuildThisFileDirectory)..\..\contentFiles\any\any\modules\_protected\**\*.*"/>
</ItemGroup>
<Target Name="CopyZipFiles" BeforeTargets="Build">
<Copy
SourceFiles="#(SourceScripts)"
DestinationFolder="$(MSBuildProjectDirectory)\modules\_protected\%(RecursiveDir)"
/>
</Target>
</Project>
Also, I found this post an implemented solutions mentioned in the post. But ended up with the same result.
Basically, I need to understand how to copy some files from the NuGet package to the destination project when installing the nuget package. And also the difference between <files> tag and <contentFiles> tag in nuspec file.
Any input from someone who has experience on this would be great!

Related

nuget contentFiles: is a binary file instead of a text file

Adding a binary file to the "contentFiles" of my nuget package leads to a build error in my C# project.
CSC : error CS2015: '...\0.0.14\contentFiles\any\any\archive.7z' is a binary file instead of a text file [...]
My goal is to have this binary file in my build output folder after dotnet build and dotnet publish.
details:
# .nuspec
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
...
<contentFiles>
<files include="archive.7z" flatten="true" buildAction="None" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="content/archive.7z" target="contentFiles\any\any" />
</files>
</package>
# folder structure
├───content
│ └───archive.7z
└───.nuspec
# .csproj file
<ItemGroup>
<PackageReference Include="my-nuget-package-name" Version="0.0.14" />
</ItemGroup>
Be sure to add the path to contentFiles "any/any/archive.7z"
<files include="any/any/archive.7z" flatten="true" buildAction="None" copyToOutput="true" />
so the correct .nuspec file should look like this:
# .nuspec
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
...
<contentFiles>
<files include="any/any/archive.7z" flatten="true" buildAction="None" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="content/archive.7z" target="contentFiles\any\any" />
</files>
</package>

Use .targets to replace file in NuGet package

I have a NuGet package that depends on another NuGet package but I want to replace one of the unmanaged DLLs with one of mine. This works well, but now I'm trying to add support for both x86 and x64 using a .targets file. When my target application builds, it pulls down the original version, not the replacement.
Here's my .nuspec:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>MyPackage</id>
<version>2.0.0</version>
<dependencies>
<group targetFramework=".NETFramework4.5.2">
<dependency id="YourPackage" version="1.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="MyPackage.targets" target="build\net452" />
<file src="..\lib\x86\thepackage.dll" target="lib\net452\x86" />
<file src="..\lib\x64\thepackage.dll" target="lib\net452\x64" />
</files>
</package>
Here's my .targets:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition="(('$(Platform)' != 'x86') AND ('$(Platform)' != 'x64'))">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)' platform. You need to specify platform (x86 or x64)." />
</Target>
<Target Name="InjectReference" AfterTargets="ResolveAssemblyReferences">
<ItemGroup Condition="'$(Platform)' == 'x86' or '$(Platform)' == 'x64'">
<Reference Include="MyPackage">
<HintPath>$(MSBuildThisFileDirectory)$(Platform)\thepackage.dll</HintPath>
</Reference>
</ItemGroup>
</Target>
</Project>
What am I doing wrong?
EDIT: If I change the .nuspec...
<file src="..\lib\x86\thepackage.dll" target="lib\net452" />
<file src="..\lib\x64\thepackage.dll" target="lib\net452" />
... then it pulls down my version but uses x86 for both x86 and x64 builds.
I solved it by putting the files in the build folder and then simply copying the target file.
.nuspec:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>MyPackage</id>
<version>2.0.0</version>
<dependencies>
<group targetFramework=".NETFramework4.5.2">
<dependency id="YourPackage" version="1.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="MyPackage.targets" target="build\net452" />
<file src="..\lib\x86\thepackage.dll" target="build\net452\x86" />
<file src="..\lib\x64\thepackage.dll" target="build\net452\x64" />
</files>
</package>
.targets:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition="(('$(Platform)' != 'x86') AND ('$(Platform)' != 'x64'))">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)' platform. You need to specify platform (x86 or x64)." />
</Target>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)$(Platform)\thepackage.dll">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

How does NuGet contentFiles work?

I'm trying to create a nuget package with content which work with different kinds of projects.
TestSource.nuspec look like this:
<contentFiles>
<files include="cs\any\TestSource.cs" buildAction="Compile" />
</contentFiles>
</metadata>
<files>
<file src="TestFolder\TestSource.cs" target="content/TestFolder" />
</files>
(the file is available both as contentFiles\cs\any\TestSource.cs and TestFolder\TestSource.cs)
The created package works fine in a "normal" project but nothing happens in a packagereference project.
I assume I'm missing something simple
Found this out myself.
You need to add the file twice in the files section
<contentFiles>
<files include="cs\any\TestSource.cs" buildAction="Compile" />
</contentFiles>
</metadata>
<files>
<file src="TestFolder\TestSource.cs" target="content/TestFolder" />
<file src="TestFolder\TestSource.cs" target="contentFiles/cs/any" />
</files>
The package will then work for both normal and packagereference projects.

Nuget not copying content

I am having a problem including a file i need in order for the project to work, here is the nuspec file that i have:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>package_name</id>
<version>1.0.1</version>
<title>x Wrapper</title>
<authors>me</authors>
<owners>me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>package desc.</description>
<releaseNotes>Bugfix to exe not being copied.</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags></tags>
<dependencies>
<dependency id="x.Common.Interfaces" version="1.0.0" />
<dependency id="x.Common.Logging" version="1.0.0" />
<dependency id="x.Wrapper.Common" version="1.0.0" />
</dependencies>
</metadata>
<files>
<file src="build\package_name.props" target="build\package_name.props" />
<file src="build\package_name.targets" target="build\package_name.targets" />
<file src="x.Wrapper\x.exe" target="content\x.exe" />
<file src="bin\Debug\package_name.dll" target="lib\net45\package_name.dll" />
</files>
</package>
When package is pushed and installed to nuget server there is only project dll + dependencies dll's but no other files are being copied into the project. Anyone with some more experience with nuget packages has idea on what could be going on ?

WIX - Unable to patch an installation after it has been patched

need a little help here...
The Error : The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch.
I have done the following...
Created an MSI version 1.0 (GUID automatically created), ProductId="*"
Created a Patch (MSP) against the against the 1.0.wixpdb, version 1.1 (Update Code has been set), ProductId="{GUID1}", pyro gave a warning about changing the product code.
Created another Patch (MSP) against the 1.1.wixpdb, version 1.2 (Kept the same Update code). ProductId="{GUID1}", cannot install.
Scenario...
Install MSI v1.0 -> Install MSP 1.1 = Works fine.
Install MSI v1.0 -> Install MSP 1.1 -> Install MSP 1.2 = FAIL, windows cannot find the application.
Install MSI v1.1 -> Install MSP 1.2 = Works fine.
To me this means that when the first patch (1.1) went down something was potentially not update, or that in creating patch 1.2 i need to take 1.0 and 1.1 into account. I have tried various options, ranging from using to within the ...
Any ideas?
Update/Patch Code...
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="WiX Patch Example Product"
Language="1033"
Version="1.0.0"
Manufacturer="Dynamo Corporation"
UpgradeCode="48C49ACE-90CF-4161-9C6E-9162115A54DD">
<Package Description="Installs a file that will be patched."
Comments="This Product does not install any executables"
InstallerVersion="200"
Compressed="yes" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<FeatureRef Id="SampleProductFeature"/>
</Product>
<Fragment>
<Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1">
<ComponentRef Id="File_1.txt" />
<ComponentRef Id="File_2.txt" />
<ComponentRef Id="File_3.txt" />
</Feature>
</Fragment>
<Fragment>
<DirectoryRef Id="SampleProductFolder">
<Component Id="File_1.txt" Guid="{d738b2a9-0dbc-4381-9efd-5801723b1569}" DiskId="1">
<File Id="File_1.txt" Name="File 1.txt" Source=".\$(var.Version)\File 1.txt" />
</Component>
<Component Id="File_2.txt" Guid="{b9b267a3-5648-4e32-9ab1-f3032980f6c2}" DiskId="1">
<File Id="File_2.txt" Name="File 2.txt" Source=".\$(var.Version)\File 2.txt" />
</Component>
<Component Id="File_3.txt" Guid="{1df728ae-333d-47c5-9558-c0923f958a8d}" DiskId="1">
<File Id="File_3.txt" Name="File 3.txt" Source=".\$(var.Version)\File 3.txt" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="SampleProductFolder" Name="Patch Sample Directory">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
Product 1.1.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="48C49ACE-90CF-4161-9C6E-9162115A54DD"
Name="WiX Patch Example Product"
Language="1033"
Version="1.1.0"
Manufacturer="Dynamo Corporation"
UpgradeCode="48C49ACE-90CF-4161-9C6E-9162115A54DD">
<Package Description="Installs a file that will be patched."
Comments="This Product does not install any executables"
InstallerVersion="200"
Compressed="yes" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<FeatureRef Id="SampleProductFeature"/>
</Product>
<Fragment>
<Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1">
<ComponentRef Id="File_1.txt" />
<ComponentRef Id="File_2.txt" />
<ComponentRef Id="File_3.txt" />
<ComponentRef Id="File_4.txt" />
</Feature>
</Fragment>
<Fragment>
<DirectoryRef Id="SampleProductFolder">
<Component Id="File_1.txt" Guid="{d738b2a9-0dbc-4381-9efd-5801723b1569}" DiskId="1">
<File Id="File_1.txt" Name="File 1.txt" Source=".\$(var.Version)\File 1.txt" />
</Component>
<Component Id="File_2.txt" Guid="{b9b267a3-5648-4e32-9ab1-f3032980f6c2}" DiskId="1">
<File Id="File_2.txt" Name="File 2.txt" Source=".\$(var.Version)\File 2.txt" />
</Component>
<Component Id="File_3.txt" Guid="{1df728ae-333d-47c5-9558-c0923f958a8d}" DiskId="1">
<File Id="File_3.txt" Name="File 3.txt" Source=".\$(var.Version)\File 3.txt" />
</Component>
<Component Id="File_4.txt" Guid="{f728f62d-91f4-4c78-b2fe-65a9f0f6043c}" DiskId="1">
<File Id="File_4.txt" Name="File 4.txt" Source=".\$(var.Version)\File 4.txt" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="SampleProductFolder" Name="Patch Sample Directory">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
Product 1.2.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="48C49ACE-90CF-4161-9C6E-9162115A54DD"
Name="WiX Patch Example Product"
Language="1033"
Version="1.2.0"
Manufacturer="Dynamo Corporation"
UpgradeCode="48C49ACE-90CF-4161-9C6E-9162115A54DD">
<Package Description="Installs a file that will be patched."
Comments="This Product does not install any executables"
InstallerVersion="200"
Compressed="yes" />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
<FeatureRef Id="SampleProductFeature"/>
</Product>
<Fragment>
<Feature Id="SampleProductFeature" Title="Sample Product Feature" Level="1">
<ComponentRef Id="File_1.txt" />
<ComponentRef Id="File_2.txt" />
<ComponentRef Id="File_3.txt" />
<ComponentRef Id="File_4.txt" />
</Feature>
</Fragment>
<Fragment>
<DirectoryRef Id="SampleProductFolder">
<Component Id="File_1.txt" Guid="{d738b2a9-0dbc-4381-9efd-5801723b1569}" DiskId="1">
<File Id="File_1.txt" Name="File 1.txt" Source=".\$(var.Version)\File 1.txt" />
</Component>
<Component Id="File_2.txt" Guid="{b9b267a3-5648-4e32-9ab1-f3032980f6c2}" DiskId="1">
<File Id="File_2.txt" Name="File 2.txt" Source=".\$(var.Version)\File 2.txt" />
</Component>
<Component Id="File_3.txt" Guid="{1df728ae-333d-47c5-9558-c0923f958a8d}" DiskId="1">
<File Id="File_3.txt" Name="File 3.txt" Source=".\$(var.Version)\File 3.txt" />
</Component>
<Component Id="File_4.txt" Guid="{f728f62d-91f4-4c78-b2fe-65a9f0f6043c}" DiskId="1">
<File Id="File_4.txt" Name="File 4.txt" Source=".\$(var.Version)\File 4.txt" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="SampleProductFolder" Name="Patch Sample Directory">
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
Patch 1.1
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Patch
AllowRemoval="yes"
Manufacturer="Dynamo Corp"
MoreInfoURL="http://www.dynamocorp.com/"
DisplayName="Sample Patch"
Description="Small Update Patch"
Classification="Update"
OptimizedInstallMode="yes">
<Media Id="8000" Cabinet="RTM.cab" CompressionLevel="none">
<PatchBaseline Id="RTM">
</PatchBaseline>
</Media>
<PatchFamilyRef Id="SamplePatchFamily"/>
</Patch>
<Fragment>
<PatchFamily Id='SamplePatchFamily' Version='1.1.0' Supersede='no'>
</PatchFamily>
</Fragment>
</Wix>
Patch 1.2
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Patch
AllowRemoval="yes"
Manufacturer="Dynamo Corp"
MoreInfoURL="http://www.dynamocorp.com/"
DisplayName="Sample Patch"
Description="Small Update Patch"
Classification="Update"
OptimizedInstallMode="yes">
<Media Id="8000" Cabinet="RTM.cab" CompressionLevel="none">
<PatchBaseline Id="RTM">
</PatchBaseline>
</Media>
<PatchFamilyRef Id="SamplePatchFamily"/>
</Patch>
<Fragment>
<PatchFamily Id='SamplePatchFamily' Version='1.2.0' Supersede='no'>
</PatchFamily>
</Fragment>
</Wix>
Making your ProductId static will help with the patching scenario, every next patch will work.
But bare in mind that running a .msi e.g. version 1.5 after your version 1.3 patch (or even version 1.0 msi) will fail with: "Another version of the product is installed..." message. So while you're sticking with the same product id only provide the patches (.msp created from .msi), and when you wish to provide a new .msi make sure you change the product id.
I'm certainly too late with this answer, but I just wasted a whole work day on this issue, and decided to put it up so others won't have to.
I guess the two rules of MSI+MSP updates are:
Never make patches from MSIs with different product IDs, they will fail to find the product and will not run
Never provide different MSIs with same product IDs, they will fail with "another version installed" and will not run
It would have been much simpler if a different MSI just overwrote the previous one with the same product ID, but there must be a good reason for the way it is...
You need a static product id across the board. You can use Orca to go in and find the product id from your 1.0 msi. Use that guid in your 1.1 and 1.2 product.wxs ProductId.