ClickOnce creates a "setup.exe" that checks for prerequisites (like the .NET Framework and XNA), downloads and installs them from Microsoft's servers, and then invokes your ClickOnce manifest. It is possible to create a setup.exe that installs just prerequisites and then does nothing.
The best way to do this is to with an MSBuild script. The creation of "setup.exe" is performed by the
<GenerateBootstrapper> task. The MSDN entry gives the various parameters you can customise (and also a minimal MSBuild example).
Because Visual Studio project files are MSBuild scripts, I find it convenient to embed it in one, as you can then just drop it into your solution. Here is a complete project file that does what you need:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Configuration Condition=" '$(Configuration)' == '' ">Generate</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Generate|AnyCPU' ">
<None Include="Readme.txt" />
<!-- Unused, in theory -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
<Copy SourceFiles="Installer\setup.exe" DestinationFiles="Installer\Install Prerequisites.exe" />
<Delete Files="Installer\setup.exe" />
(Put the above in a text file and give it a
.csproj extension. It's tested in Visual C# Express 2010. I've also put in some tasks to rename the output to something nice.)
<BootstrapperPackage> is used to indicate items to the
BootstrapperItems parameter (like in regular projects using ClickOnce), but this naming is arbitrary. The above project file generates an install for XNA 4 and .NET 4 Client Profile. If you wanted to change these, you could copy them from a dummy project with ClickOnce configured.
If you want to have your installer launch a program, after it is done installing prerequisites, you can set the
(Note that the
GenerateBootstrapper task, as used by ClickOnce, won't appear in your regular project files - it's invoked somewhere inside