这个 MSDeploy NullReferenceException 是什么?

发布于 2025-01-06 02:21:58 字数 2780 浏览 0 评论 0原文

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

对我可以尝试的东西有什么想法吗?

When I run MSDeploy from a build script, I get this NullReferenceException. The funny thing is, the project deploys. This has been driving me crazy. Note: This is a web site project, not a web application project.

I'm using this in my build targets file:

    <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>

Here's the error:

"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

Any ideas for something I can try?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱你不解释 2025-01-13 02:21:58

尝试在 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>

Try using ContinueOnError="true" on the MSDeploy Elements as the following code:

<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>
爱格式化 2025-01-13 02:21:58

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

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

I had the same issue; and was just able to address it using the fix described here:
http://forums.iis.net/p/1187159/2016131.aspx#2016131

For me, using the VSMSDeploy task is not an option, as we run x64 servers and web apps. Visual Studio only runs x86 versions of msbuild and msdeploy, and so VSMSDeploy only works for x86 servers and sites. I'm using the appHostConfig provider to store IIS config, and appHostConfig can't sync an x64 site to an x86 instance of msdeploy.

自此以后,行同陌路 2025-01-13 02:21:58

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

I just ran into the same thing. I wasn't able to figure out what the problem was, but I was able to work around it by using VSMSDeploy instead of MSDeploy. Both tasks are in the same DLL and there are examples of using it in Microsoft.Web.Publishing.targets.

‘画卷フ 2025-01-13 02:21:58

我能够使用 Web 部署项目

I was able to get the deploy working with a Web Deploy Project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文