microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

Allow DotNetFramework ASPNET Core projects to be dockerized #134

Closed neoGeneva closed 3 months ago

neoGeneva commented 6 years ago

Currently targeting DotNetFramework (e.g. net471) and build an ASPNET Core project isn't able to be dockerized, it's disabled in the UI, and if a dcproj and Dockerfile are set up manually then the following error is thrown:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(279,5): error : Value cannot be null.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(279,5): error : Parameter name: stream

And that's because the Microsoft.Docker.Templates.windows.dotnetframework.aspnetcore.docker-compose.vs.debug.yml template doesn't exist in Microsoft.Docker.dll

Currently, for me, moving to .NET Core isn't viable because I have too many, very old dependencies that can't be moved to dotnet core.

I've managed to trick the the dcproj into compiling by adding the following to my project to convince the docker tools it's a console project (by setting the ProjectCapability value to be empty when calling ResolveAppType):


  <Import Project="$(MSBuildExtensionsPath)\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets" Condition="Exists('$(MSBuildExtensionsPath)\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets')" />
  <Target Name="DockerResolveAppType">
    <ResolveAppType ProjectDirectory="$(MSBuildProjectDirectory)" ProjectCapability="" OutputType="$(OutputType)" ProjectTypeGuids="$(ProjectTypeGuids)">
      <Output TaskParameter="AppType" PropertyName="DockerAppType" />
    </ResolveAppType>
  </Target>

Although this allows me to compile and get the container up with msvsmon.exe running, I still have to docker exec to start the site and manually attach from inside VS, which is a bit of a pain, and from what I can tell it's just because it's only because docker tools trys to check if the project is compatible.

haniamr commented 6 years ago

@neoGeneva thanks for reporting, this scenario is not supported at the moment and that's why it is blocked from the UI.

We'll add that work item in our backlog and triage it accordingly.

neoGeneva commented 6 years ago

Great, thanks @haniamr

odin88 commented 5 years ago

Any update on this ?