debugging 从Visual Studio容器化的独立Angular前端+ .net后端编译

ghhaqwfi  于 2023-10-24  发布在  Angular
关注(0)|答案(1)|浏览(177)

我想使用docker-compose从Visual Stuidio 17.7同时调试后端.net项目和前端Angular项目。这些项目在一个解决方案中。请帮助我修复此错误:当我尝试启动docker-compose项目的新示例时,无论是否调试,我在构建docker-compose项目时都遇到错误:
Error MSB3030 Could not copy the file "..\myangularfrontend.exe" because it was not found. docker-compose C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 4879
显然,我的独立angular项目不包含.exe文件。
我试着为我的docker-compose.yml文件运行docker-compose builddocker-compose up。它工作得很好-构建项目,为前端和后端创建和启动容器。
Angular前端项目已从模板独立Angular Application. Docker文件添加到Angular项目中的解决方案:

FROM node:18.10 as node
COPY package.json /app/package.json
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
RUN npm install

COPY . /app
EXPOSE 4200
CMD npm start

Docker-compose.yml:

services:
  myangularfrontend:
    build:
     context: ./myangularfrontend
     dockerfile: Dockerfile
    command: "ng serve --open --host 0.0.0.0 --port 4200 --disable-host-check"
    ports:
     - "4200:4200"

  mybackendserver:
    image: ${DOCKER_REGISTRY-}mybackendserver
    build:
      context: .
      dockerfile: Mybackendserver/Dockerfile

docker-compose项目的LaunchSettings:

{
  "profiles": {
    "Docker Compose": {
      "commandName": "DockerCompose",
      "commandVersion": "1.0",
      "composeLaunchAction": "LaunchBrowser",
      "composeLaunchServiceName": "mybackendserver",
      "composeLaunchUrl": "{Scheme}://localhost:{ServicePort}",
      "serviceActions": {
        "mybackendserver": "StartDebugging",
        "myangularfrontend": "StartWithoutDebugging"
      }
    }
  }
}

docker-compose.dcproj:

<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
  <PropertyGroup Label="Globals">
    <ProjectVersion>2.1</ProjectVersion>
    <DockerTargetOS>Linux</DockerTargetOS>
    <ProjectGuid>94ec4b9d-bfa4-47ae-8d36-f7c661ce2a1e</ProjectGuid>
    <DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
    <DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
    <DockerServiceName>mybackendserver</DockerServiceName>
  </PropertyGroup>
  <ItemGroup>
    <None Include="docker-compose.override.yml">
      <DependentUpon>docker-compose.yml</DependentUpon>
    </None>
    <None Include="docker-compose.yml" />
    <None Include=".dockerignore" />
  </ItemGroup>
</Project>
7xllpg7q

7xllpg7q1#

错误来自.dcproj,它试图“帮助”Angular项目。你可以通过将com.microsoft.visual-studio.project-name标签添加到你的Angular服务来禁用它。

更新了Docker-compose.yml:

services:
  myangularfrontend:
    build:
     context: ./myangularfrontend
     dockerfile: Dockerfile
    labels:
      com.microsoft.visual-studio.project-name: ""
    command: "ng serve --open --host 0.0.0.0 --port 4200 --disable-host-check"
    ports:
     - "4200:4200"

  mybackendserver:
    image: ${DOCKER_REGISTRY-}mybackendserver
    build:
      context: .
      dockerfile: Mybackendserver/Dockerfile

相关问题