我正在努力将Docker支持添加到一个运行良好的既定asp应用程序中。我希望通过点击“添加Docker支持”并查看“ F5体验”是什么来利用VS2017 Docker特性。幸运的是,我立即被一些有点神秘的错误所困扰
1>------ Build started: Project: docker-compose, Configuration: Release Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: The "ResolveProjectInputAndOutput" task failed unexpectedly.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: System.ArgumentNullException: Value cannot be null.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: Parameter name: path1
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: at System.IO.Path.Combine(String path1, String path2)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: at Microsoft.Docker.BuildTasks.ResolveProjectInputAndOutput.ResolveRelativeOutputAssemblyPath(TargetOS targetOS, TargetFramework targetFramework, DockerDevelopmentMode developmentMode)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: at Microsoft.Docker.BuildTasks.ResolveProjectInputAndOutput.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(80,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
我跳到有问题的文件,这是这里的一个具体问题:
<Target Name="DockerResolveProjectInputAndOutput">
<ResolveProjectInputAndOutput ProjectDirectory="$(MSBuildProjectDirectory)" DockerComposeProjectPath="$(DockerComposeProjectPath)" OutputPath="$(OutputPath)" References="@(Reference)" TargetFileName="$(TargetFileName)" TargetPath="$(TargetPath)" />
</Target>
因此,我在proj文件中花了一个高峰,以查看是否存在任何特定于Docker的问题。我在这里只找到一个参考:
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
似乎某些配置未正确完成,并导致了此问题,但运气不好,无法确定具体的位置。
答案 0 :(得分:0)
在我的情况下,问题是这样的:我们有很多配置(Dev,Test,Beta,Prod,Debug和Release)。但是,在该应用程序的项目文件中,我试图向其添加容器支持,但我们没有用于调试的<PropertyGroup>
部分。该部分就是OutputPath
所在的地方。
奇怪的是,即使在Dev
配置中运行,我仍然收到错误消息。
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Dev\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>