1

当我从构建脚本运行 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

有什么想法可以尝试吗?

4

4 回答 4

2

尝试在 MSDeploy 元素上使用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>
于 2012-03-27T20:29:32.890 回答
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 实例。

于 2012-05-23T06:31:35.280 回答
0

我只是遇到了同样的事情。我无法弄清楚问题出在哪里,但我能够通过使用 VSMSDeploy 而不是 MSDeploy 来解决它。这两个任务都在同一个 DLL 中,并且在 Microsoft.Web.Publishing.targets 中有使用它的示例。

于 2012-02-16T17:29:44.003 回答
0

我能够使用Web Deploy Project进行部署。

于 2012-06-11T17:55:32.933 回答