Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to run post build steps on .NET Core Debug #879

Closed
flgarrid opened this issue Apr 4, 2019 · 5 comments
Closed

Not able to run post build steps on .NET Core Debug #879

flgarrid opened this issue Apr 4, 2019 · 5 comments

Comments

@flgarrid
Copy link

flgarrid commented Apr 4, 2019

When debugging in Docker, if I install some npm packages in the base image, they are not preserved in the Debug instance.

My Dockerfile is super simple:

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base  
RUN apt-get update && \  
    apt-get -y install build-essential curl gnupg pkg-config libcairo2-dev libjpeg-dev libgif-dev python-pypdf2  
RUN curl -sL https://deb.nodesource.com/setup_8.x  | bash -  
RUN apt-get -y install nodejs  
WORKDIR /src  
COPY ["Node/package.json", "."]  
RUN npm install --production --silent && mkdir -p /app/bin/Debug/netcoreapp2.2/Node/ && mv node_modules /app/bin/Debug/netcoreapp2.2/Node/

Which makes me think that the folder /app/bin/Debug is being overwritten after the .NET Core publish stage is done.

Is there any way I can run the npm install command after the .NET Core app is published?
(Or as a workaround, try to copy the node_modules folder to /app/bin/Debug/netcoreapp2.2/Node/`)

Thank you!

@philliphoff
Copy link
Contributor

@flgarrid When debugging, VS Code will map your local app directory into (by default) the /app folder of the container. That is, the application project is not actually built as part of creation of the image used for debugging.

Would it work to install the NPM packages in your local application output folder (e.g. as part of build), before debugging?

@flgarrid
Copy link
Author

flgarrid commented Apr 4, 2019

Thank you @philliphoff.

I used my local NPM packages, but one of them is platform-specific (I'm running a Windows machine and a Linux container), so it must be installed on the container.

@philliphoff
Copy link
Contributor

@flgarrid Ah, I see. I'll have to think about how that could work; since the entire application directory hierarchy is mapped in, I'm not sure how that could be resolved other than to move the Node files outside of the application directory hierarchy altogether. Can you provide a bit more context on your project (e.g. the structure/arrangement of its output between the .NET and Node pieces)?

@flgarrid
Copy link
Author

flgarrid commented Apr 4, 2019

@philliphoff I'm using Microsoft.AspNetCore.NodeServices to run Node.js code from .NET Core. The key package that is platform-specific in Node.js is https://github.com/Automattic/node-canvas.

We invoke the Node.js code by using await nodeServices.InvokeAsync() and it runs great both in Linux and in Windows (with the platform-specific packages installed).

All of the Node code is running in the /Node folder.

@bwateratmsft
Copy link
Contributor

Fixed in #1245 although it will require the user to create a custom task that depends on the docker-run task, and in turn the launch config must use said custom task as the preLaunchTask.

@bwateratmsft bwateratmsft added this to the 0.9.0 milestone Sep 18, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants