0

Без докера все работало, писал вот так.

private static string CompileCs(string filePath)
        {
            var pc = new Process
            {
                StartInfo =
                {
                    Verb = "runas",
                    Arguments = $@"""C:\Program Files\dotnet\sdk\6.0.300\Roslyn\bincore\csc.dll"" -r:""C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.5\System.Private.CoreLib.dll"" -r:""C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.5\System.Console.dll"" -r:""C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.5\System.Runtime.dll"" -r:""C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.5\System.Runtime.InteropServices.RuntimeInformation.dll"" ""{filePath}.cs"" -out:""{filePath}.dll""",
                    FileName = "dotnet",
                    UseShellExecute = false,
                    RedirectStandardError = true
                }
            };
            pc.Start();
            pc.WaitForExit();
            var err = pc.StandardError.ReadToEnd();
            return err;
        }

С докером, поменял код на

        private static string CompileCs(string filePath)
        {
            var pc = new Process
            {
                StartInfo =
                {
                    Verb = "runas",
                    Arguments = @"usr/bin/dotnet/sdk/6.0.300/Roslyn/bincore/csc.dll",
                    FileName = "dotnet",
                    UseShellExecute = false,
                    RedirectStandardError = true,
                }
            };
            pc.Start();
            string err = pc.StandardError.ReadToEnd();
            pc.WaitForExit();
            return err;
        }

Но получаю ошибку:

Could not execute because the specified command or file was not found.\r\nPossible reasons for this include:\r\n * You misspelled a built-in dotnet command.\r\n * You intended to execute a .NET program, but dotnet-usr/bin/dotnet/sdk/6.0.300/Roslyn/bincore/csc.dll does not exist.\r\n * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.\n

Сам DockerFile

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/asp.net:6.0 AS build
WORKDIR /src
COPY ["SolutionsTester/SolutionsTester.Web.csproj", "SolutionsTester/"]
COPY ["SolutionsTester.DataAccess/SolutionsTester.DataAccess.csproj", "SolutionsTester.DataAccess/"]
COPY ["SolutionTester.Domain/SolutionTester.Domain.csproj", "SolutionTester.Domain/"]
RUN dotnet restore "SolutionsTester/SolutionsTester.Web.csproj"
COPY . .
WORKDIR "/src/SolutionsTester"
RUN dotnet build "SolutionsTester.Web.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SolutionsTester.Web.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SolutionsTester.Web.dll"]
3
  • @"/usr/bin/...
    – aepot
    20 мая 2022 в 9:51
  • @aepot Немного другая ошибка: "realpath(/usr/bin/dotnet/sdk/6.0.300/Roslyn/bincore/csc.dll) failed: Not a directory\nCould not execute because the specified command or file was not found.\r\nPossible reasons for this include:\r\n * You misspelled a built-in dotnet command.\r\n * You intended to execute a .NET program, but dotnet-/usr/bin/dotnet/sdk/6.0.300/Roslyn/bincore/csc.dll does not exist.\r\n * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.\n", 20 мая 2022 в 10:19
  • Ну, значит у вас нет такого файла по указанному пути.
    – aepot
    20 мая 2022 в 10:21

1 ответ 1

0

Правильный путь: /usr/share/dotnet/sdk/6.0.300/Roslyn/bincore/csc.dll -r: /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Private.CoreLib.dll - r:/usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Console.dll - r:/usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.dll - r:/usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.InteropServices.RuntimeInformation.dll {filePath}.cs -out:{filePath}.dll

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.