I'm trying to prevent my services from losing their settings (credentials and other options) on major upgrades in my WiX installer.
I followed the advice here, and I'm trying to use
<InstallExecuteSequence>
<DeleteServices>NOT UPGRADINGPRODUCTCODE</DeleteServices>
</InstallExecuteSequence>
But my services are still being reinstalled on upgrades, losing my credentials and other service settings on each upgrade.
In the log, it looks like my condition is being honored only once. I see
MSI (s) (6C:E8) [16:52:53:944]: Skipping action: DeleteServices (condition is false)
and then a few hundred lines later, I see
MSI (s) (6C:A4) [16:52:54:873]: Doing action: DeleteServices
So it appears to me that the second DeleteServices is my problem. Can anyone tell me how I can suppress that second one, or what I'm doing to cause it?
I'm using the WiX toolset 3.7.
Here's my code, guids removed obviously.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id='*' Name='My Product' Language='1033'
Version='1.0.6' Manufacturer='Me' UpgradeCode='PUT-GUID-HERE' >
<Package Description='My Product' Platform='x86' Id='*'
Manufacturer='Me' InstallerVersion='200' Compressed='yes' />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/>
<InstallExecuteSequence>
<DeleteServices>NOT UPGRADINGPRODUCTCODE</DeleteServices>
</InstallExecuteSequence>
<Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='AgentDir' Name='Agent'>
<Component Id='Binaries' Guid='PUT-GUID-HERE' Win64='no'>
<File Id='AgentExe' Source='../MyProduct/MyExe.exe' KeyPath='yes' ProcessorArchitecture='x86' />
<ServiceInstall Id="TheServiceInstall" Description="[ProductName]" EraseDescription="no" DisplayName="[ProductName]" ErrorControl="normal" Interactive="no" Name="[ProductName]" Start="auto" Type="ownProcess" Vital="yes">
</ServiceInstall>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id='CompleteInstall' Title='My Product' Level='1'>
<ComponentRef Id='Binaries' />
</Feature>
</Product>
</Wix>
Thanks!
It seems that my problem was not that the services were being deleted, it was the install of the new product that was causing me to lose my service settings.
I added this into my InstallExecuteSequence block, and it seems to have done the trick
<InstallServices>NOT WIX_UPGRADE_DETECTED</InstallServices>
Thank you for the help Stephen!
In a major upgrade remember you will run two execute sequences, one to uninstall the old product and another to install the new product. I suspect your problem comes from the uninstall of the older product. Does the older product have the "... AND not UPGRADINGPRODUCTCODE" condition to suppress the DeleteServices action when the old product is uninstalled? You will have to find a way to patch the old product to insert that condition before you attempt the upgrade.
Related
Package Manager in VS2019 is totally broken for me.
When I attempt to view packages for my solution the UI just says "Error occurred" with the details below, '' is not a valid version string
My build environment is heavily customized with custom targets, and packages are loaded via an out-of-VS process called "corext." So my question is what file is being parsed when attempting to load the package manager? I have a nuget.config at the root of my enlistment as well as under AppData\Roaming\NuGet which I've deleted with no results. I've tried clearing out all the nuget caches. I've tried all of the suggestions in this post without luck. If I could get any more logs at all I might be able to unblock myself. I get exactly the same results in VS 2017. Any ideas?
After countless hours of pain it was suggested to me to look for a <PackageReference> node with an unresolvable version number. To do this I went to any project in my tree and ran: msbuild /pp:pp.log foo.csproj. This generates a preprocessing log. In that log file I did a "find all instances" of "PackageReference". The first hit was a PackageReference in Directory.Build.props without a version number. The fix was to add (any) version number. I'll surely need to put in the right version number but the solution will look like this:
First, please check your nuget.config file at the root of my enlistment. Usually, when you have a new nuget.config file over the root directory path of your project.
The current project and all projects in the subdirectory will use this nuget.config rather than the global nuget.config file(AppData\Roaming\NuGet). It will add the new pakageSource and will overwrite the same name of the packagesource from the global nuget.config file.
See this document about this info.
1) Please enter the nuget.config at the root of your enlistment.
Check if you have such node like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
..............
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="test123" value="C:\xxxx\" />
<add key="github source" value="https://xxxxxxxxxxxxxxxxxxxx"/>
</packageSources>
<disabledPackageSources>
<add key="test123" value="true" />
</disabledPackageSources>
</configuration>
If so, you should check every packagesource path and make sure there is no such a space on every packagesource in case of spelling mistakes.
Or you could use disabledPackageSources node to disable any packagesources except nuget.org.
Like this:
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="test123" value="C:\xxxx\" />
<add key="github source" value="https://xxxxxxxxxxxxxxxxxxxx"/>
.........
.........
</packageSources>
<disabledPackageSources>
<add key="test123" value="true" />
<add key="github source" value="true" />
..........
</disabledPackageSources>
Then, close VS and restart your project to test again.
Or you could just delete such nuget.config to check whether there is a error node in it. Also, make a backup.
2) Second, you could run this below under Tools-->NuGet Package Manager-->Package Manager Console.
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
3) please try to a new project to check whether the issue persists in the new project. This can determine if there is a problem with nuget.config in that project.
Besides, you could try to share the nuget.config file with us.
In addition, if these do not help, please try the following steps:
a) disable any third party extensions under Extensions-->Manage Extensions
b) If these do not help, try to repair VS or update VS if there is a new update.
I am new to Sitecore and Glass.Mapper tools. I am working with Visual Studio 2013 and Sitecore 8.1 for a solution I have begun working on (not the author).
Due to other questions I have observed, I will try to demonstrate what my solution now has in it to remove build errors.
My packages.config includes the following:
<package id="Glass.Mapper" version="4.2.1.188" targetFramework="net45" />
<package id="Glass.Mapper.Sc" version="4.2.1.188" targetFramework="net45" />
My nuget.config includes the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="nuget v2" value="https://www.nuget.org/api/v2" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
I have added these as project references to each of these Dlls from our Packages directory, which also includes the following in a few of the projects:
<package id="Glass.Mapper.Sc.CastleWindsor" version="3.3.0.25" targetFramework="net45" />
<package id="Glass.Mapper.Sc.Core" version="4.2.1.188" targetFramework="net45" />
<package id="Glass.Mapper.Sc.Mvc-5" version="3.3.0.45" targetFramework="net45" />
Solution errors have been reduced from several hundred to ~20, mostly due to this issue, and the Metadata file "..." could not be found errors which appear since dependent projects fail to generate their project Dlls.
We cannot upgrade Nuget in place, and we cannot perform upgrades using Manage Nuget Packages for Solution due to code in place which references deprecated methods in key packages.
If you browse packages on nuget.org with your web browser, you can guess the pattern for viewing a specific version of a package. So, version 4.2.1.188 of GlassMapper will use the URL https://www.nuget.org/packages/Glass.Mapper/4.2.1.188
There, I see a message saying
The owner has unlisted this package. This could mean that the package is deprecated or shouldn't be used anymore.
So the package exists, so existing packages should be able to restore it, but the owner has delisted it to reduce the probability that new projects will start using it. Interestingly the package owner has delisted all versions of the package, suggesting the package is deprecated.
Anyway, as I mentioned, normally the package can still be restored (that's the point of unlisting vs deleting). So my best guess is that the version of NuGet that works with Visual Studio 2013 doesn't support unlisted packages as it's really, really old.
You could download nuget.exe from nuget.org/downloads, restore from the command line and then use Visual Studio. Otherwise you'll probably need to upgrade to a newer version of Visual Studio.
I have installed AsyncUsageAnalyzers for my common project (which is a NuGet package), and I want the rules to be enforced in all of my packages/applications that depends on it.
I have changed the severity of the UseConfigureAwait rule, and a .ruleset has been created.
I have read on https://stackoverflow.com/a/20271758/2663813 that I needed to have a NuGet package with a given structure. That assertion has been confirmed here https://stackoverflow.com/a/46115423/2663813
What I have now:
build/Common.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="My common analyzer rules" Description="The rules that are enforced on all of my projects" ToolsVersion="10.0">
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
<Rule Id="UseConfigureAwait" Action="Error" />
</Rules>
</RuleSet>
build/My.Package.Id.targets
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Common.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>
In my .csproj
<Import Project="build\My.Package.Id.targets" />
My question is : Now that I've done that and that the rules are correctly applied on my project, how do I add the files under build/ inside the NuGet package, inside the build/ folder? I know that I could do that with a .nuspec file as mentionned in the links, but I'd like to do that with the new .csproj syntax.
Sorry for posting too quickly, I just found the solution right under my eyes:
In the page https://learn.microsoft.com/en-us/dotnet/core/tools/csproj#nuget-metadata-properties , in the comments, MarkPflug gives the translation, and quotes
https://learn.microsoft.com/en-us/nuget/schema/msbuild-targets#pack-scenarios for reference.
In my case, I need to use PackagePath as follows (Content would also work, but as Martin Ullrich pointed out, None is a better choice here):
<ItemGroup>
<None Include="build\**" Pack="True" PackagePath="build\" />
</ItemGroup>
I am new in wix and creating a window service. I have created my service and successfully added in window service but when I run it stopped due to error.
<?xml version="1.0" encoding="UTF-8"?>
<?define Name = "New Window Service" ?>
<?define Manufacturer = "GAT" ?>
<?define UpgradeCode = "{0d4fb541-bb66-4df8-bdab-893564e191fc}" ?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
>
<Product Id="*" Name="$(var.Name)" Manufacturer="$(var.Manufacturer)" Version="1.0.0.0" UpgradeCode="$(var.UpgradeCode)" Language="1033">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="GAT.GATAC.ServiceLayer.WindowsServiceHost.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="$(var.Name)" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)">
<CreateFolder />
<File Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe" KeyPath="yes" Vital="yes" />
<File Id="GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
Name="MyProduct.exe.config"
Source="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config"
Vital="yes"
KeyPath="no"
DiskId="1" />
<RemoveFile Id="ALLFILES" Name="*.*" On="both" />
<util:XmlFile Id="ModifyServiceLocation" Action="setValue" ElementPath="/configuration/connectionStrings/add[\[]#name='DefaultConnection'[\]]/#connectionString" File="D:\Projects\GATAC\GAT.GATAC.ServiceLayer.WindowsServiceHost\bin\Release\GAT.GATAC.ServiceLayer.WindowsServiceHost.exe.config" Value="Data Source=[DB_SERVER];Initial Catalog=[DB_DATABASE];User Id=[DB_USER];Pwd=[DB_PASSWORD]"/>
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
DisplayName="$(var.Name)"
Description="A Test Service that logs dummy text on an interval to a text file."
Start="auto"
ErrorControl="normal"
/>
<ServiceControl Id="ServiceInstaller"
Stop="both"
Remove="both"
Name="GAT.GATAC.ServiceLayer.WindowsServiceHost"
Wait="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="$(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetFileName)" />
</Feature>
</Product>
</Wix>
when I saw in installation folder of service there is only exe file so how to copy all dependencies of window service in this folder my code is following.When I copy files manually in installation folder it works.Do I need to harvest
Yes, you need to include ALL files in your wxs as components you want to install.
If you have a few dependencies, you can just add them as File components yourself. If there are a lot of files consider using heat to generate the wxs file for you and you can copy the file elements into your wxs code. If the file dependencies may change frequently, consider using heat to always generate the wxs and include it as a linked file in your main installer project.
Ideally all your dependencies are being included in the GAT.GATAC.ServiceLayer.WindowsServiceHost project's bin folder so you can just use $(var.GAT.GATAC.ServiceLayer.WindowsServiceHost.TargetDir)DependencyFileName as the Source for the file.
The error occurs only on one machine.
Attempts
Wrong paths
I thought the path of any source may be wrong, so I opened the NuGet.Config to check and the 3 paths are correct and there!
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<add key="Nightly ASP.NET Web Stack" value="http://www.myget.org/F/aspnetwebstacknightly/" />
<add key="Bind Solution" value="W:\Cloud\Dropbox\Bind Defaults\Nuget Repository" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
</activePackageSource>
</configuration>
Nuget.exe not exist
Checked on .nuget folder and .exe is in the directory!
Checked in Path of windows and there is!
I tried to run the command manually and it run successfully!
nuget install packages.config -source "" -NonInteractive -RequireConsent -solutionDir "W:\C
lients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB\ "
Full error:
Error 1 The system cannot find the path specified. CreditoImobiliarioBB.Domain
Error 2 The command ""W:\Clients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB.nuget\NuGet.exe" install "W:\Clients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB\CreditoImobiliarioBB.Model\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "W:\Clients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB\ " " exited with code -1. CreditoImobiliarioBB.Domain
Considerations
Only projects that have local packages (Source is key="Bind Solution" value="W:\Cloud\Dropbox\Bind Defaults\Nuget Repository") is that they are in trouble. And recently the location of packages moved to another directory (in this case to W:\Cloud\Dropbox\Bind Defaults\Nuget Repository).
I had a similar problem recently, I fixed it by doing this:
Update Visual Studio to the latest version. (Extensions and Updates - Product Updates)
Update Nugget to the latest version. (Extensions and Updates - Visual Studio Gallery)
Clear the Package Cache. (Options - Package Manager)
Rebuild the solution.
Hope it helps.
I ran into a similar problem with NuGet.exe and WG.exe for WebGrease. I realized that with my Virus Protection turned on, it wasn't allowing the .exe files to come down properly. Once I disabled my Virus Protection, I was able to get everything I need (company is using McAfee).