Я пытаюсь настроить CI / CD для нашего ASP. NET MVC приложения. Я могу получить исходный код с GitHub для создания сборки через CodeBuild. Но у меня возникают проблемы со сборкой приложения через msbuild на Windows Server 2019 версии windows -base: 2.0. Проблема: «Microsoft.WebApplications.targets не найден». Ниже мой файл buildspe c .yml:
version: 0.2
env:
variables:
SOLUTION: .\Application.sln
PACKAGE_DIRECTORY: .\packages
DOTNET_FRAMEWORK: 4.7.2
PROJECT: Application
phases:
build:
commands:
- .\nuget restore
- >-
msbuild $env:PROJECT.csproj
/p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK
/p:Configuration=Release
/p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\
artifacts:
files:
- '**/*'
Журналы из CodeBuild:
[Container] 2020/08/02 21:24:23 Waiting for agent ping
[Container] 2020/08/02 21:24:23 Waiting for DOWNLOAD_SOURCE
[Container] 2020/08/02 21:24:27 Phase is DOWNLOAD_SOURCE
[Container] 2020/08/02 21:24:27 CODEBUILD_SRC_DIR=C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository
[Container] 2020/08/02 21:24:27 YAML location is C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\buildspec.yml
[Container] 2020/08/02 21:24:27 Processing environment variables
[Container] 2020/08/02 21:24:33 Moving to directory C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository
[Container] 2020/08/02 21:24:33 Registering with agent
[Container] 2020/08/02 21:24:33 Phases found in YAML: 1
[Container] 2020/08/02 21:24:33 BUILD: 2 commands
[Container] 2020/08/02 21:24:33 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2020/08/02 21:24:33 Phase context status code: Message:
[Container] 2020/08/02 21:24:33 Entering phase INSTALL
[Container] 2020/08/02 21:24:33 Phase complete: INSTALL State: SUCCEEDED
[Container] 2020/08/02 21:24:33 Phase context status code: Message:
[Container] 2020/08/02 21:24:33 Entering phase PRE_BUILD
[Container] 2020/08/02 21:24:33 Phase complete: PRE_BUILD State: SUCCEEDED
[Container] 2020/08/02 21:24:33 Phase context status code: Message:
[Container] 2020/08/02 21:24:34 Entering phase BUILD
[Container] 2020/08/02 21:24:34 Running command .\nuget restore
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin'.
C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj(130,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
WARNING: Error reading msbuild project information, ensure that your input solution or project file is valid. NETCore and UAP projects will be skipped, only packages.config files will be restored.
All packages listed in packages.config are already installed.
[Container] 2020/08/02 21:24:54 Running command msbuild $env:PROJECT.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/2/2020 9:24:54 PM.
Project "C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application.sln" (1) is building "C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj" (2) on node 1 (default targets).
C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj(130,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Done Building Project "C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj" (default targets) -- FAILED.
Done Building Project "C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application.sln" (default targets) -- FAILED.
Build FAILED.
"C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application.sln" (default target) (1) ->
"C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj" (default target) (2) ->
C:\codebuild\tmp\output\src547721943\src\github.com\githubaccount\repository\Application\Application.csproj(130,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.82
[Container] 2020/08/02 21:24:55 Command did not exit successfully msbuild $env:PROJECT.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\ exit status 1
[Container] 2020/08/02 21:24:56 Phase complete: BUILD State: FAILED
[Container] 2020/08/02 21:24:56 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: msbuild $env:PROJECT.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\. Reason: exit status 1
[Container] 2020/08/02 21:24:56 Entering phase POST_BUILD
[Container] 2020/08/02 21:24:56 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/08/02 21:24:56 Phase context status code: Message:
[Container] 2020/08/02 21:24:56 Expanding base directory path: .
[Container] 2020/08/02 21:24:57 Assembling file list
[Container] 2020/08/02 21:24:57 Expanding .
[Container] 2020/08/02 21:24:57 Expanding file paths for base directory .
[Container] 2020/08/02 21:24:57 Assembling file list
[Container] 2020/08/02 21:24:57 Expanding **/*
[Container] 2020/08/02 21:24:58 Found 208 file(s)
[Container] 2020/08/02 21:25:01 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED