Specifying a VC++ Redistributable version for ClickOnce prerequisite - visual-c++

My ClickOnce application uses a third party tool that requires the Visual C++ 2005 redistributable. The third party tool will not work if only the VC++ 2008 redistributable is installed. However, in Visual Studio 2008, the ClickOnce prerequisites do not allow a version to be specified for the VC++ redistributable; it will add a VC++ 2008 prerequisite, which makes sense most of the time. However, in this situation, an earlier version is required. ClickOnce is required, so merge modules are out of the question. Any ideas of how to specify the version?

If you can find a machine with VS 2005 installed, the solution shouldn't be too hard. You have the ability to customize what appears in the Prerequisites dialog on the Publish tab of your project.
On a machine with VS 2005 installed, go to \Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages and copy the vsredist_x86 folder to the machine you are publishing from.
Rename the folder, call it vsredist_x86_2005 or something similar.
Inside the folder, edit the \en\package.xml file. Change the <String Name="DisplayName"> tag to something that makes sense (Visual C++ 2005 Runtime Libraries (x86)) to differentiate it from the existing 2008 package.
Copy the folder to C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages.
Restart Visual Studio if it is open.
Now, when you open the Prerequisites dialog you should see a new entry for the 2005 package. I didn't completely test this solution so I may have missed a few details but hopefully this gets you started.

I believe you can open the manifest file for your app and modify the versions of the redists your app should be linking against. The listings in the manifest should match what you have in your C:\Windows\WinSxS dirs. There is a CodeProject page that gives a good description of using different redistributables.

I just installed Visual Studio 2005. Here is an original bootstrapper:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\
\en\package.xml
<?xml version="1.0" encoding="utf-8" ?>
<Package
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
Name="DisplayName"
Culture="Culture"
>
<!-- Defines a localizable string table for error messages-->
<Strings>
<String Name="DisplayName">Visual C++ Runtime Libraries (x86)</String>
<String Name="Culture">en</String>
<String Name="AdminRequired">You do not have the permissions required to install Visual C++ Runtime Libraries (x86). Please contact your administrator.</String>
<String Name="InvalidPlatformWin9x">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows 95. Contact your application vendor.</String>
<String Name="InvalidPlatformWinNT">Installation of Visual C++ Runtime Libraries (x86) is not supported on Windows NT 4.0. Contact your application vendor.</String>
<String Name="GeneralFailure">A failure occurred attempting to install Visual C++ Runtime Libraries (x86).</String>
</Strings>
</Package>
\product.xml
<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Microsoft.Visual.C++.8.0.x86"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="vcredist_x86.exe"/>
</PackageFiles>
<InstallChecks>
<MsiProductCheck Property="VCRedistInstalled" Product="{A49F249F-0C91-497F-86DF-B2585E8E76B7}"/>
</InstallChecks>
<!-- Defines how to invoke the setup for the Visual C++ 8.0 redist -->
<!-- TODO: Needs EstrimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
<Commands Reboot="Defer">
<Command PackageFile="vcredist_x86.exe"
Arguments=' /q:a '
>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9X" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>
\vcredist_x86.exe
SHA1: 95040f80b0d203e1abaec4e06e0ec0e01c507d03

Related

Reboot not required for .NET 4.0 after VS2012 runtime installation

My WPF application was running fine when built on VS2010 and using WiX3.5. I changed to VS2012 and installed the VS2012 runtime using Wix as below:
<DirectoryRef Id="TARGETDIR">
<Merge Id="VC110RedistCRT" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_CRT_x86.msm" DiskId="1" Language="0"/>
<Merge Id="VC110RedistMFC" SourceFile="C:\Program Files (x86)\Common Files\Merge Modules\Microsoft_VC110_MFC_x86.msm" DiskId="1" Language="0"/>
</DirectoryRef>
<Feature Id="VC110Redist" Title="Visual C++ 11.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
<MergeRef Id="VC110RedistCRT"/>
<MergeRef Id="VC110RedistMFC"/>
</Feature>
Earlier with VS2010, application installation on new machine used to ask for reboot while installing .NET framework. Now with VS2012, it doesn't ask for reboot and application is running fine also.
I just wanted to know the possible reason and any side effects of this. Any details of how the C++ runtime and .Net Framework installation work with each other will be helpful.
Thanks

SGEN : error : Mixed mode assembly

Can anyone help me im getting this error when im publishing my project on release mode
SGEN : error : Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
Please help me im stuck on this issue.
There is an answer in Microsoft Support (https://support.microsoft.com/en-za/help/2572158/sgen-mixed-mode-assembly-is-built-against-version-v2-0-50727-of-the-ru) which says:
In order to use mixed mode assemblies in 4.0, it must be configured in the configuration file for Sgen
Resolution
Add the information below to the sgen.exe.config file located at the following location: ..\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
For Visual Studio 2017 the path is different and can be like: c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\
For Build/Publish in Release Mode please follow below step
create a new file as sgen.exe.config
keep below code in that file
<?xml version ="1.0"?>
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
Please keep this file in below path
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools Folder
And for x64
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64 Folder
Now restart Visual Studio
Open Project in Administrator mode and Build/Publish in Release Mode.

Wix merge modules vc++ 9.0 SP1 not installing

I have a Wix installer that I have added the merge modules to for the last version of the VC++ 9.0 runtime. I've opened the .msm files with Orca to verify that they are the latest version, 9.0.30729.6161. I include the CRT msm in my installer just as it is done in the example on the Wix site:
<Fragment>
<DirectoryRef Id="TARGETDIR">
<?if $(var.Platform) = x64 ?>
<Merge Id="VCRedist" SourceFile="$(env.CommonProgramFiles)\Merge Modules\Microsoft_VC90_CRT_x86_x64.msm" DiskId="1" Language="0"/>
<?else?>
<Merge Id="VCRedist" SourceFile="$(env.CommonProgramFiles)\Merge Modules\Microsoft_VC90_CRT_x86.msm" DiskId="1" Language="0"/>
<?endif ?>
</DirectoryRef>
</Fragment>
Then in my features file:
<MergeRef Id="VCRedist" />
When I run the installer with logging on, I can see that the files are moved to the side by side directory, C:\Windows\winsxs. When I run my application, it does not recognize that the CRT is available.
If I run the redistributable installer from here, everything works as expected. I've tried including all the merge modules with no luck.
Any ideas?
Using the policy merge modules got it working for me.

Linker error when using v110_xp: "cannot open file ',5.01'"

I am building some Visual C++ DLL and EXE projects with Visual Studio 2012. When building with the default platform toolset v110 the build is successful, but when building with the Windows XP compatible platform toolset v110_xp it fails with the following linker error in each project:
LINK : fatal error LNK1104: cannot open file ',5.01'
Note that if I change the platform from Win32 to x64 the errors change to:
LINK : fatal error LNK1104: cannot open file ',5.02'
This can be easily reproduced by creating a new EXE project from the "Empty Project" template in Visual Studio and adding some *.cpp file defining int main() {return 6;} . It will build successfully until you change the platform toolset from v110 to v110_xp.
Why does this happen and how can I build these projects successfully with Windows XP compatibility?
In the project properties, under Linker -> System, make sure that you set the SubSystem property (either to Console for console applications, or to Windows for DLLs and non-console applications).
If you use common property sheets (*.props) to set project properties across all of your projects, you can add something like this to make sure that SubSystem is assigned a valid value if the project doesn't specify one explicitly.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<Link>
<SubSystem Condition="'%(Link.SubSystem)'=='' Or '%(Link.SubSystem)'=='NotSet'">Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
</Project>
Why does this happen?
Choosing the v110_xp platform toolset automatically sets the Minimum Required Version linker setting to 5.01 or 5.02, because this is the version of 32-bit and 64-bit Windows XP, respectively.
When the the Minimum Required Version property is set, regardless of whether SubSystem is also set, Visual Studio tries to add both properties to the linker's command line arguments. This results in ,5.01 when SubSystem is not set (instead of the intended /SUBSYSTEM:CONSOLE,5.01), and the linker understands this as trying to specify a file named ",5.01".
The latter is a bug in Visual Studio (not directly related to v110_xp). When Minimum Required Version is set and SubSystem isn't, VS should either ignore Minimum Required Version or issue a warning, but it shouldn't send malformed arguments to the linker.

Missing prerequisites for Visual C++ in Visual Studio 2012

I've recently installed vs2012 and I've updated my ClickOnce application. To be more precise, the first time I've opened my C++ project (on which depends my primary c# project) I've not updated it and everything worked fine. VS 2012 was still able to see the Visual C++ 2010 prerequisite. Later on I've updated my project by changing the Platform Toolset to "Visual Studio 2012 (v110)" under Properties->Configuration Properties->General.
In the meantime I've installed even other software and now I discovered that I'm no more able to add the Visual C++ prerequisite to my project for the ClickOnce publishing. The Visual C++ 2010 Runtime Libraries (x64) prerequisite is marked with a yellow triangle and it is missing. Ideally I'd like to update to Visual C++ 2012 Runtime Libraries x64 (and x86), but even this prerequisite is missing.
I guess it is due to the fact that in the folder C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages the corresponding package (vcredist_x64) is empty. I've also noticed that in the list of installed programs in the Control Panel I had Microsoft Visual C++ 2010 x64 and x86 installed, both the Redistributable version and the Runtime version (I think they where installed previously with Visual Studio 2010), while I was missing the Visual C++ 2012 files. Hence I'm arguing that the Visual C++ 2012 didn't come together with Visual Studio 2012, isn't it? I've even tried to install the Visual C++ 2012 Redistributable x64 packages by downloading them and now they are listed in my installed programs 8only the Redistributable, not the Runtime version).
However the prerequisite is still missing. How can I solve this? I've even thought about manually copying the bootstrapper package for Visual C++ 2010 located in the...\v7.0A\Bootstrapper\Packages folder and changing it manually for C++ 2012 but I do not know what I should write in product.xml under <MsiProductCheck Property="VCRedistInstalled" Product=?>. It seems that the product GUID to insert this information can be obtained with Bootstrapper Manager, but this program is throwing a lot of exception and I do not know how to do it. As a second solution is it safe to simply copying the package for Visual C++ 2010 from \\v7.0A\Bootstrapper\Packages\Bootstrapper\Packages to \v8.0A\Bootstrapper\Packages?
Go to \v8.0A\Bootstrapper\Packages and make sure you have the vcredist_x86 folder.
In that folder you should have an "en" folder, that should remain there, you are missing
product.xml
vcredist_x86.exe
You can download the required .exe from http://go.microsoft.com/fwlink/?LinkID=266495&clcid=0x409
As for the product.xml
<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Microsoft.Visual.C++.11.0.x86"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="vcredist_x86.exe" HomeSite="VCRedistExe"/>
</PackageFiles>
<InstallChecks>
<MsiProductCheck Property="VCRedistInstalled" Product="{6C772996-BFF3-3C8C-860B-B3D48FF05D65}"/>
</InstallChecks>
<!-- Defines how to invoke the setup for the Visual C++ 11.0 redist -->
<!-- TODO: Needs EstrimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
<Commands Reboot="Defer">
<Command PackageFile="vcredist_x86.exe"
Arguments=' /q:a '
>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9X" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>
For those looking for a similar answer for the 2012 x64 vcredist, here's one I cobbled together that seems to work. Note the download link is
http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Microsoft.Visual.C++.11.0.x64"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="vcredist_x64.exe" HomeSite="VCRedistExe"/>
</PackageFiles>
<InstallChecks>
<MsiProductCheck Property="VCRedistInstalled" Product="{CF2BEA3C-26EA-32F8-AA9B-331F7E34BA97}"/>
</InstallChecks>
<!-- Defines how to invoke the setup for the Visual C++ 11.0 redist -->
<!-- TODO: Needs EstimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
<Commands Reboot="Defer">
<Command PackageFile="vcredist_x64.exe"
Arguments=' /q:a '
>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on any platform other than x64 -->
<FailIf Property="ProcessorArchitecture" Value="AMD64" Compare="ValueNotEqualTo" String="InvalidOS"/>
<!-- Block install on Vista or below -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="6.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>

Resources