简体   繁体   English

How to remove docker support from an ASP.NET Core project?

[英]How to remove docker support from an ASP.NET Core project?

I've installed Visual Studio 2017 Community RC with .NET Core and Docker (Preview) so I could try the "Add docker support" on my project.

Unfortunatelly I couldn't get things work together (win8.1 + docker toolbox + hyperv engine + docker tools seems like not works together well) so I decided to remove docker support from my project.

There was no any menu item to remove docker support so I just deleted all docker related files from the solution.

Currently I get an error when I try to build/rebuild/clean/...:

Error MSB4018 The "CleanWorkspace" task failed unexpectedly. System.IO.FileNotFoundException: The file 'D:\dev\AspNetCore\docker-compose.yml' was not found.

Error MSB4018 The "PrepareForCompile" task failed unexpectedly. System.IO.FileNotFoundException: The file 'D:\dev\AspNetCore\docker-compose.yml' was not found.

I tried to delete bin, obj, .vs folders without luck.

If you look in your project folder you should see a user settings file called <projectname>.csproj.user .如果您查看项目文件夹,您应该会看到一个名为<projectname>.csproj.user的用户设置文件。

Within this file it may look like the following在此文件中,它可能如下所示

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <ActiveDebugProfile>Docker</ActiveDebugProfile> </PropertyGroup> </Project>

Just change只是改变

<ActiveDebugProfile>Docker</ActiveDebugProfile>

to

<ActiveDebugProfile>Debug</ActiveDebugProfile>

You may be able to just delete this file as it is user settings and there may be nothing else relevant in the file, please check.您可以删除此文件,因为它是用户设置,并且文件中可能没有其他相关内容,请检查。

Please backup before any changes.请在进行任何更改之前进行备份。

Go to your project dependencies and check if you have any container package added. Go 到您的项目依赖项并检查您是否添加了任何容器 package。 If you do, remove the container package and rebuild.如果这样做,请移除容器 package 并重建。

I ran into same situation and wanted to remove Docker support for my project Visual Studio 2017 and .NET Framework 4.6.1 project (not asp.Net Core) but i believe this will work for Asp.Net Core projects too:我遇到了同样的情况,想删除对我的项目 Visual Studio 2017 和 .NET Framework 4.6.1 项目(不是 asp.Net Core)的 Docker 支持,但我相信这也适用于 Asp.Net Core 项目:

  • In the project explorer, look for a project named "docker-compose"在项目资源管理器中,查找名为“docker-compose”的项目

  • Right click and select option "Unload project".右键单击并 select 选项“卸载项目”。 As soon as this只要这
    project is unloaded you will see the IIS/browser options for running your project项目已卸载,您将看到用于运行项目的 IIS/浏览器选项

If you ever wanted to re-enable docker support, please select the project "docker-compose" and click "Reload Project" this will remove all IIS/browser options and set Docker如果您想重新启用 docker 支持,请 select 项目“docker-compose”并单击“重新加载项目”这将删除所有 IIS/浏览器选项并设置 ZC5FD214CDD0D2B3B4272E73B02

Goto launchSettings.json file Locataed in: <YourProjectName>/Properties/launchSettings.json转到launchSettings.json文件位于: <YourProjectName>/Properties/launchSettings.json

Remove This lines:删除此行:

 "Docker": { "commandName": "Docker", "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/...", "publishAllPorts": true, "useSSL": true }

I have a similar answer because my ActiveDebugProfile was already set to debug but that didn't really remove docker support from my project.我有一个类似的答案,因为我的 ActiveDebugProfile 已经设置为调试,但这并没有真正从我的项目中删除 docker 支持。

Right click on the solution in VS and click "Edit MyProjectName.csproj" in your.csproj file comment out (or delete) the tag called DockerComposeProjectPath in the PropertyGroup with your target framework右键单击 VS 中的解决方案,然后单击.csproj 文件中的“编辑 MyProjectName.csproj” 使用您的目标框架注释掉(或删除)PropertyGroup 中名为 DockerComposeProjectPath 的标记

 <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> <.--<DockerComposeProjectPath>..\docker-compose dcproj</DockerComposeProjectPath>-->

Next, next to the Debug button where is says "Docker", there is a dropdown list where you select your start up project.接下来,在显示“Docker”的“调试”按钮旁边,有一个下拉列表,您可以在其中 select 启动项目。 Change this from "Docker" To the name of your project.将其从“Docker”更改为您的项目名称。

Lastly you will remove the "docker-compose" and the "Dockerfile" from your project, build to confirm everything is okay and you should be good to go最后,您将从项目中删除“docker-compose”和“Dockerfile”,构建以确认一切正常,您应该对 go

  1. Remove the reference in Dependencies > Packages Microsoft.VisualStudio.Azure.Containers.Tools.Targets删除Dependencies > Packages Microsoft.VisualStudio.Azure.Containers.Tools.Targets 中的引用

  2. Remove DockerFile拆下DockerFile

  3. Remove these lines in launchSettings.jsonlaunchSettings.json中删除这些行

    "Docker": { "commandName": "Docker", "launchBrowser": true, "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", "publishAllPorts": true, "useSSL": true } “Docker”:{“commandName”:“Docker”,“launchBrowser”:真,“launchUrl”:“{Scheme}://{ServiceHost}:{ServicePort}/swagger”,“publishAllPorts”:真,“useSSL” : 真的 }

  4. Remove this code in .Csproj.Csproj中删除此代码

DockerDefaultTargetOS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 支持 Docker 的 ASP.NET Core:连接被拒绝 - ASP.NET Core with Docker support: Connection refused 如何从asp.net项目中删除Bootstrap? - How do I remove Bootstrap from asp.net project? 如何将我的项目从 asp.net mvc 迁移到 asp.net core? - How to migrate my project from asp.net mvc to asp.net core? 无法从docker连接到sql服务器支持asp.net核心项目 - Can not connect to sql server from docker supported asp.net core project Docker 上的 Asp.Net Core - Asp.Net Core on Docker 有没有办法可以从 ASP.NET 核心项目中删除数据库迁移? - Is there a way I can remove DB migration from an ASP.NET Core project? 如何从项目根目录获取 appsettings 到 ASP.NET Core 2.0 和 EF Core 2.0 中的 IDesignTimeDbContextFactory 实现 - How to get appsettings from project root to IDesignTimeDbContextFactory implementation in ASP.NET Core 2.0 and EF Core 2.0 如何在asp.net core中从多个项目中获取媒体上传公共项目的路径 - How to get Path of Common Project for Media Upload from Multiple Project in asp.net core 对Asp.Net Core的EntityFramework支持 - EntityFramework support for Asp.Net Core 从asp.net核心应用程序中删除多项选择 - Remove multiple selection from asp.net core application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM