Web安装程序更换是否在VS2012中创建MSI?

时间:2012-09-13 09:04:23

标签: installation visual-studio-2012 web-setup-project

我在VS2010中有一个项目,它使用Web安装项目进行部署。我现在正在考虑将其迁移到VS2012,并且必须找到替换设置例程。

我的要求:

  • 在开发计算机上创建部署程序包/安装程序的一步构建。
  • 可在服务器上运行的安装程序/例程 - 无需Visual Studio。
  • Visual Studio与服务器之间没有直接交互。我必须通过RDP会话复制安装文件。
  • Web应用程序(MVC)和Windows服务的设置,最好捆绑在一个安装程序中(新要求目前无法解决din Web Setup项目)。
  • 可以在设置过程中运行EF迁移(目前通过custom action完成)。

我应该从哪里开始?我应该看看VS2012中改进的发布功能吗?我应该看看Wix吗?还有别的吗?

1 个答案:

答案 0 :(得分:1)

深入研究Visual Studio 2012并试图按照预期的方式使用它,而不是反对它,我们最终使用了Web部署包。它不会创建MSI文件,而是创建一个可以轻松导入目标计算机上的IIS的zip文件。

Windows服务项目已添加为对网站项目的引用。这样,服务的二进制文件包含在网站的bin目录中。来自实体框架的migrate.exe文件被添加为bin目录中的链接,这意味着它也已部署。

最后,我们向项目添加了一个project.wpp.targets文件,该文件运行所需的命令来安装和启动服务,并获得部署中包含的服务配置文件。这对我们有用,但并不是那么优雅(例如,不同配置的网站安装路径是硬编码的。)

project.wpp.targets文件:

<?xml version="1.0" encoding="utf-8" ?>
<!--
*** WARNING ***
This file is cached by visual studio and changes won't take effect until 
visual studio is restarted. When editing this file, it is better to run the
build step for packaging from the command line (a VS command prompt).
There are some problems with dependencies not being correctly identified that
way, but at least the archive.xml file can be verified from the command prompt.

msbuild orderportal.csproj /t:package /p:Configuration=SysTest /p:DeployOnBuild=true;DeployTarget=Package
-->

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <IncludeRunMigrations>TRUE</IncludeRunMigrations>
    <AfterAddIisSettingAndFileContentsToSourceManifest Condition="'$(AfterAddIisSettingAndFileContentsToSourceManifest)'==''">
      $(AfterAddIisSettingAndFileContentsToSourceManifest);
      RunMigrations;
      ServiceInstall;
    </AfterAddIisSettingAndFileContentsToSourceManifest>

    <IncludeServiceInstall>TRUE</IncludeServiceInstall>
    <BeforeAddContentPathToSourceManifest Condition="'$(BeforeAddContentPathToSourceManifest)' == ''">
      $(BeforeAddContentPathToSourceManifest);
      ServiceUnInstall;
    </BeforeAddContentPathToSourceManifest>

    <DeploymentDir Condition="'$(Configuration)'=='SysTest' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\SysTest\</DeploymentDir>
    <DeploymentDir Condition="'$(Configuration)'=='IntTest' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\IntTest\</DeploymentDir>
    <DeploymentDir Condition="'$(Configuration)'=='Prod' AND '$(DeploymentDir)'==''">c:\inetpub\wwwroot\</DeploymentDir>

    <CopyAllFilesToSingleFolderForPackageDependsOn>
      IncludeServicesAppConfig;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

  </PropertyGroup>
  <Target Name="RunMigrations" Condition="'$(IncludeRunMigrations)' == 'TRUE'">
    <Message Text="Adding migration running"/>
    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
        <path>$(DeploymentDir)bin\migrate.exe /startupdirectory:$(DeploymentDir)bin Topsi.Core.dll /startUpConfigurationFile:$(DeploymentDir)web.config</path>
        <waitAttempts>1</waitAttempts>
        <waitInterval>60000</waitInterval>
        <dontUseCommandExe>true</dontUseCommandExe>
        <AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
      </MsDeploySourceManifest>
    </ItemGroup>
  </Target>

  <Target Name="ServiceUnInstall" Condition="'$(IncludeServiceInstall)' == 'TRUE'">
    <Message Text="Adding service uninstall" />
    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
        <path>net stop "Topsi Schedule Service $(Configuration)"</path>
        <waitAttempts>1</waitAttempts>
        <waitInterval>60000</waitInterval>
        <dontUseCommandExe>true</dontUseCommandExe>
        <AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
      </MsDeploySourceManifest>
      <MsDeploySourceManifest Include="runCommand">
        <path>C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u $(DeploymentDir)bin\Topsi.Services.exe</path>
        <waitAttempts>1</waitAttempts>
        <waitInterval>60000</waitInterval>
        <dontUseCommandExe>true</dontUseCommandExe>
        <AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
    </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
  <Target Name="ServiceInstall" Condition="'$(IncludeServiceInstall)' == 'TRUE'">
    <Message Text="Adding service install"/>
    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
        <path>C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe $(DeploymentDir)bin\Topsi.Services.exe</path>
        <waitAttempts>1</waitAttempts>
        <waitInterval>60000</waitInterval>
        <dontUseCommandExe>true</dontUseCommandExe>
        <AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
      </MsDeploySourceManifest>
      <MsDeploySourceManifest Include="runCommand">
        <path>net start "Topsi Schedule Service $(Configuration)"</path>
        <waitAttempts>1</waitAttempts>
        <waitInterval>60000</waitInterval>
        <dontUseCommandExe>true</dontUseCommandExe>
        <AdditionalProviderSettings>waitInterval;waitAttempts;dontUseCommandExe</AdditionalProviderSettings>
      </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
  <Target Name="IncludeServicesAppConfig">
    <ItemGroup>
      <_CustomFiles Include="..\Services\bin\$(Configuration)\Topsi.Services.exe.config">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </_CustomFiles>

      <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>bin\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
</Project>
相关问题