2012-02-14 68 views
1

当我从构建脚本运行MSDeploy时,我得到这个NullReferenceException。有趣的是,该项目部署。这一直让我疯狂。注意:这是一个网站项目,而不是一个Web应用程序项目。这是什么MSDeploy NullReferenceException?

我在我的构建目标文件中使用这样的:

<ItemGroup>  
     <DeploySource Include="DirPath"> 
      <Path>C:\TFS\MySiteBranch\PrecompiledWeb\Source</Path> 
      <ComputerName>myComputer</ComputerName> 
      <UserName>anAdminAccount</UserName> 
      <Password>itsPassword</Password> 
     </DeploySource> 
    </ItemGroup> 

    <ItemGroup> 
     <TestDeployDest Include="DirPath"> 
      <Path>C:\TFS_Build\POC\Test</Path> 
      <ComputerName>myComputer</ComputerName> 
      <UserName>anAdminAccount</UserName> 
      <Password>itsPassword</Password> 
     </TestDeployDest> 
    </ItemGroup>  

    <Target name="Deploy"> 

     <PropertyGroup> 
      <WhatIf Condition="'$(WhatIf)'==''">false</WhatIf> 
      <MSDeployPath Condition="'$(MSDeployPath)'==''">C:\Program Files\IIS\Microsoft Web Deploy V2</MSDeployPath> 
     </PropertyGroup> 

     <MSDeploy Condition="'@(TestDeployDest)'!=''" 
      Whatif="$(WhatIf)" 
      Verb="sync" 
      Source="@(DeploySource)" 
      Destination="@(TestDeployDest)" 
      ExePath="$(MSDeployPath)" 
     /> 
</target> 

这里的错误:

"C:\TFS\MySiteBranch\Source\source.csproj" (Deploy target) (1) -> 
(Deploy target) -> 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: The "MSDeploy" task failed unexpectedly.\r [C:\TFS\MySiteBranch\Source\source.csproj] 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.\r [C:\TFS\MySiteBranch\Source\source.csproj] 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: at Microsoft.Web.Publishing.Tasks.Common.Utility.MsDeployEndOfExecuteMessage(Boolean bSuccess, String destType, String destRoot, TaskLoggingHelper Log)\r [C:\TFS\MySiteBranch\Source\source.csproj] 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: at Microsoft.Web.Publishing.Tasks.MSDeploy.Execute()\r [C:\TFS\MySiteBranch\Source\source.csproj] 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\TFS\MySiteBranch\Source\source.csproj] 

C:\TFS\MySiteBranch\Source\Deploy.Targets(54,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutio 

的东西,我可以尝试任何想法?

+0

可能是由于项目中的深层次结构。你使用的是什么版本的Visual Studio? – Bill 2012-02-14 05:50:14

+0

我正在使用VS 2010和TFS 2010.我也必须将自己的项目文件放在一起,因为这是一个网站,本地不使用它。我已验证项目文件,并且所有目标文件都在运行。 – 2012-02-14 14:09:43

回答

0

我刚碰到同样的事情。我无法弄清楚问题所在,但是我可以通过使用VSMSDeploy而不是MSDeploy来解决它。这两个任务都在同一个DLL中,并有在Microsoft.Web.Publishing.targets中使用它的示例。

2

尝试使用ContinueOnError = “真”在MSDeploy元素如下面的代码:

<ItemGroup>  
     <DeploySource Include="DirPath"> 
      <Path>C:\TFS\MySiteBranch\PrecompiledWeb\Source</Path> 
      <ComputerName>myComputer</ComputerName> 
      <UserName>anAdminAccount</UserName> 
      <Password>itsPassword</Password> 
     </DeploySource> 
    </ItemGroup> 

    <ItemGroup> 
     <TestDeployDest Include="DirPath"> 
      <Path>C:\TFS_Build\POC\Test</Path> 
      <ComputerName>myComputer</ComputerName> 
      <UserName>anAdminAccount</UserName> 
      <Password>itsPassword</Password> 
     </TestDeployDest> 
    </ItemGroup>  

    <Target name="Deploy"> 

     <PropertyGroup> 
      <WhatIf Condition="'$(WhatIf)'==''">false</WhatIf> 
      <MSDeployPath Condition="'$(MSDeployPath)'==''">C:\Program Files\IIS\Microsoft Web Deploy V2</MSDeployPath> 
     </PropertyGroup> 

     <MSDeploy ContinueOnError="true" Condition="'@(TestDeployDest)'!=''" 
      Whatif="$(WhatIf)" 
      Verb="sync" 
      Source="@(DeploySource)" 
      Destination="@(TestDeployDest)" 
      ExePath="$(MSDeployPath)" 
     /> 
</target> 
1

我有同样的问题;而只是能够使用此处描述的修复来解决它: http://forums.iis.net/p/1187159/2016131.aspx#2016131

对我来说,使用VSMSDeploy任务是不是一种选择,因为我们运行x64服务器和Web应用程序。 Visual Studio只运行x86版本的msbuild和msdeploy,因此VSMSDeploy仅适用于x86服务器和站点。我正在使用appHostConfig提供程序来存储IIS配置,并且appHostConfig无法将x64站点同步到msdeploy的x86实例。