当我从构建脚本运行MSDeploy时,我得到了这个NullReferenceException。有趣的是,该项目部署。这让我发疯了。注意:这是一个网站项目,而不是Web应用程序项目。
我在构建目标文件中使用它:
<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 :(得分:2)
尝试在MSDeploy Elements上使用 ContinueOnError =“true”作为以下代码:
<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 :(得分: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实例。
答案 2 :(得分:0)
我刚刚碰到了同样的事情。我无法弄清问题是什么,但我能够通过使用VSMSDeploy而不是MSDeploy来解决它。这两个任务都在同一个DLL中,并且在Microsoft.Web.Publishing.targets中有使用它的示例。
答案 3 :(得分:0)
我能够使用Web Deploy Project进行部署。