简体   繁体   English

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

[英]Web Setup replacement to create MSI in VS2012?

I have a project in VS2010 that uses Web Setup projects for deployment. 我在VS2010中有一个项目,它使用Web安装项目进行部署。 I'm now looking into migrating it to VS2012 and have to find a replacement setup routine. 我现在正在考虑将其迁移到VS2012,并且必须找到替换设置例程。

The requirements I have: 我的要求:

  • One-step build to create a deploy package/installer on a dev machine. 在dev计算机上创建部署包/安装程序的一步构建。
  • Setup program/routine that can be run on the server - without Visual Studio available. 可以在服务器上运行的安装程序/例程 - 没有Visual Studio可用。
  • No direct interaction between Visual Studio and the server. Visual Studio与服务器之间没有直接交互。 I have to copy the setup files over through an RDP session. 我必须通过RDP会话复制安装文件。
  • Setup of web applications (MVC) and Windows Services, preferably bundled in one single installer (new requirement currently not solve din Web Setup project). Web应用程序(MVC)和Windows服务的设置,最好捆绑在一个安装程序中(新要求目前无法解决din Web Setup项目)。
  • Possibility to run EF Migrations as part of setup (currently done through a custom action ). 可以在设置过程中运行EF迁移(目前通过自定义操作完成 )。

Where should I start? 我应该从哪里开始? Should I look into the improved publishing features in VS2012? 我应该看看VS2012中改进的发布功能吗? Should I look at Wix? 我应该看看Wix吗? Something else? 别的什么?

Looking deeper into Visual Studio 2012 and trying to work with it the way it was intended, instead of against it, we ended up using web deploy packages. 深入研究Visual Studio 2012并尝试按照预期的方式使用它,而不是反对它,我们最终使用Web部署包。 It doesn't create an MSI file, but instead a zip file that can be easily imported into IIS on the target machine. 它不会创建MSI文件,而是创建一个可以轻松导入目标计算机上的IIS的zip文件。

The Windows service project was added as a reference to the web site project. Windows服务项目已添加为对网站项目的引用。 That way the binaries for the service are included in the bin directory of the web site. 这样,服务的二进制文件包含在网站的bin目录中。 The migrate.exe file from Entity framework was added as a link from the bin directory which means it is deployed too. 来自实体框架的migrate.exe文件作为bin目录中的链接添加,这意味着它也已部署。

Finally we added a project.wpp.targets file to the project that runs the required commands to install and start the service and to get the service's config file included in the deploy. 最后,我们将project.wpp.targets文件添加到项目中,该文件运行所需的命令来安装和启动服务,并获取部署中包含的服务配置文件。 This worked for us, but is not really that elegant (eg the install paths of the site for different configurations is hard coded). 这对我们有用,但并不是那么优雅(例如,不同配置的站点的安装路径是硬编码的)。

The project.wpp.targets file: 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM