1

So, I've recently come across a project I would like to dockerise which is built in dotnet (I should caveat with the fact that I am not a .net developer)

The repo can be found here for reference:

https://github.com/observerly/ASCOM.Alpaca.Simulators

I have given it my best attempt to setup the following Dockerfile to be able to containerise this app:

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app 

# copy NuGet config
COPY NuGet.config .

# copy csproj and restore as distinct layers
COPY *.sln .
COPY ASCOM.Alpaca.Simulators/*.csproj ./ASCOM.Alpaca.Simulators/
COPY Camera.Simulator/*.csproj ./Camera.Simulator/
COPY CoverCalibratorSimulator/*.csproj ./CoverCalibratorSimulator/
COPY DomeSimulator/*.csproj ./DomeSimulator/ 
COPY FilterWheelSimulator/*.csproj ./FilterWheelSimulator/ 
COPY FocuserSimulator/*.csproj ./FocuserSimulator/ 
COPY ObservingConditionsSimulator/*.csproj ./ObservingConditionsSimulator/ 
COPY OmniSim.Tools/*.csproj ./OmniSim.Tools/ 
COPY RotatorSimulator/*.csproj ./RotatorSimulator/ 
COPY SafetyMonitorSimulator/*.csproj ./SafetyMonitorSimulator/ 
COPY SwitchSimulator/*.csproj ./SwitchSimulator/ 
COPY TelescopeSimulator/*.csproj ./TelescopeSimulator/ 

# copy WindowsBase.Vector
COPY WindowsBase.Vector/*.sln ./WindowsBase.Vector/ 
COPY WindowsBase.Vector/WindowsBase.Vector/*.csproj ./WindowsBase.Vector/WindowsBase.Vector/ 

RUN dotnet restore 

# copy everything else and build app
COPY ASCOM.Alpaca.Simulators/. ./ASCOM.Alpaca.Simulators/
COPY Camera.Simulator/. ./Camera.Simulator/
COPY CoverCalibratorSimulator/. ./CoverCalibratorSimulator/
COPY DomeSimulator/. ./DomeSimulator/ 
COPY FilterWheelSimulator/. ./FilterWheelSimulator/ 
COPY FocuserSimulator/. ./FocuserSimulator/ 
COPY ObservingConditionsSimulator/. ./ObservingConditionsSimulator/ 
COPY OmniSim.Tools/. ./OmniSim.Tools/ 
COPY RotatorSimulator/. ./RotatorSimulator/ 
COPY SafetyMonitorSimulator/. ./SafetyMonitorSimulator/ 
COPY SwitchSimulator/. ./SwitchSimulator/ 
COPY TelescopeSimulator/. ./TelescopeSimulator/ 

WORKDIR /app/ASCOM.Alpaca.Simulators
RUN dotnet publish -c Release -o out 

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app 

COPY --from=build /app/ASCOM.Alpaca.Simulators/out ./
ENTRYPOINT ["dotnet", "ASCOM.Alpaca.Simulators.dll"]

However, I am encountering the following error stack:

#44 4.204 /app/TelescopeSimulator/AstronomyFunctions.cs(282,23): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.205 /app/TelescopeSimulator/AstronomyFunctions.cs(379,47): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.205 /app/TelescopeSimulator/AstronomyFunctions.cs(379,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.205 /app/TelescopeSimulator/AstronomyFunctions.cs(395,47): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.205 /app/TelescopeSimulator/AstronomyFunctions.cs(395,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.205 /app/TelescopeSimulator/MountFunctions.cs(25,51): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.206 /app/TelescopeSimulator/MountFunctions.cs(25,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.206 /app/TelescopeSimulator/MountFunctions.cs(64,52): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(64,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(97,51): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(97,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(123,52): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(123,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.207 /app/TelescopeSimulator/MountFunctions.cs(159,42): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.208 /app/TelescopeSimulator/MountFunctions.cs(159,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.208 /app/TelescopeSimulator/MountFunctions.cs(168,43): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.209 /app/TelescopeSimulator/MountFunctions.cs(168,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.209 /app/TelescopeSimulator/MountFunctions.cs(177,41): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.210 /app/TelescopeSimulator/MountFunctions.cs(177,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.210 /app/TelescopeSimulator/TelescopeHardware.cs(1497,43): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.210 /app/TelescopeSimulator/TelescopeHardware.cs(1517,42): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.211 /app/TelescopeSimulator/TelescopeHardware.cs(1670,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.212 /app/TelescopeSimulator/TelescopeHardware.cs(1786,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.212 /app/TelescopeSimulator/TelescopeHardware.cs(1843,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.212 /app/TelescopeSimulator/TelescopeHardware.cs(1933,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.212 /app/TelescopeSimulator/TelescopeHardware.cs(158,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.213 /app/TelescopeSimulator/TelescopeHardware.cs(163,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.213 /app/TelescopeSimulator/TelescopeHardware.cs(168,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.214 /app/TelescopeSimulator/TelescopeHardware.cs(173,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.214 /app/TelescopeSimulator/TelescopeHardware.cs(193,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.214 /app/TelescopeSimulator/TelescopeHardware.cs(200,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.215 /app/TelescopeSimulator/TelescopeHardware.cs(202,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.215 /app/TelescopeSimulator/TelescopeHardware.cs(219,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.215 /app/TelescopeSimulator/TelescopeHardware.cs(224,24): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.216 /app/TelescopeSimulator/TelescopeHardware.cs(249,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.216 /app/TelescopeSimulator/TelescopeHardware.cs(254,25): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.216 /app/TelescopeSimulator/TelescopeHardware.cs(265,23): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.217 /app/TelescopeSimulator/TelescopeHardware.cs(274,23): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]
#44 4.217 /app/TelescopeSimulator/TelescopeHardware.cs(279,23): error CS0246: The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?) [/app/TelescopeSimulator/TelescopeSimulator.csproj]

Could anyone provide me with any pointers to be able to solve this niggling issue?

My suspicions are that it has something to do with the nested WindowsBase.Vector situation ...

1 Answer 1

1

Your mistake is that you never copy the code for the WindowsBase.Vector project into the container. Add the last line in this block.

# copy everything else and build app
COPY ASCOM.Alpaca.Simulators/. ./ASCOM.Alpaca.Simulators/
COPY Camera.Simulator/. ./Camera.Simulator/
COPY CoverCalibratorSimulator/. ./CoverCalibratorSimulator/
COPY DomeSimulator/. ./DomeSimulator/ 
COPY FilterWheelSimulator/. ./FilterWheelSimulator/ 
COPY FocuserSimulator/. ./FocuserSimulator/ 
COPY ObservingConditionsSimulator/. ./ObservingConditionsSimulator/ 
COPY OmniSim.Tools/. ./OmniSim.Tools/ 
COPY RotatorSimulator/. ./RotatorSimulator/ 
COPY SafetyMonitorSimulator/. ./SafetyMonitorSimulator/ 
COPY SwitchSimulator/. ./SwitchSimulator/ 
COPY TelescopeSimulator/. ./TelescopeSimulator/ 
COPY WindowsBase.Vector/. ./WindowsBase.Vector/

but instead of copying each project separately, you can just do

# copy everything else and build app
COPY . .

and copy everything at once.

Sign up to request clarification or add additional context in comments.

2 Comments

I managed to get to this solution before your answer @HansKillian, but thank you for your help nonetheless, this would have worked! I prefer to COPY . . (much less verbose, hey!) :) Thank you again.
Copying everything is also more robust, since it doesn't break when you add a new project. Anyway, glad you got it solved!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.