- NetCoreWin
- CppLibWin
- Set the solution active configuration to 'Debug'. To do this, right-click on the solution, then Properties > Configuration Properies > Configuration Manager ...
- Build
CppLibWin
- Build and run
NetCoreWin
- NetCoreWin
- CppLibLinux: this has the exact same codes from
CppLibWin
- Set solution active configuration to
Unix
. - Setup Docker container using the following Dockerfile content
FROM ubuntu
RUN apt-get update && apt-get install -y openssh-server g++ gdb gdbserver
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Docker commands
docker build -f <path_to_Dockerfile> -t <image_name> .
docker run -d -P --name test_sshd <image_name>
docker port test_sshd 22
- Connect the container to Visual Studio
Tools > Options > Cross Platform > Connection Manager. Username is
root
, pass isscreencast
. - Build CppLibLinux
- Create some folder for the final build
- Copy the built .so from step 4
docker cp test_sshd:/root/projects/CppLibLinux/bin/x64/Unix/libCppLibLinux.so <path_to_final_build_folder>
- Build
NetCoreWin
and copy output folder (Unix) to the final build folder Now inside the build folder you have content like this
build_folder
netcoreapp2.0
NetCoreWin.dll
...
libCppLibLinux.so
linuxso.Dockerfile
Content of the dockerfiler is
FROM microsoft/dotnet:2.0.4-runtime
COPY ./netcoreapp2.0 /app
COPY ./libCppLibLinux.so /app
WORKDIR /app
CMD [ "dotnet", "./NetCoreWin.dll" ]
- Final build to docker and verify Inside the final build folder, run commands
docker build -t pinvoke_linux -f linuxso.Dockerfile .
docker run pinvoke_linux