I have been trying to use CodeBuild to setup a codepipeline for a .NET based application. Below are the details -
- Buildspec file -
version: 0.2 env: variables: PROJECT: Triyo.API DOTNET_FRAMEWORK: 4.7.2 phases: build: commands: - echo start-main-solution-build - nuget.exe restore TriyoAPI.sln - cd TriyoCore.API - msbuild $env:TriyoCore.API.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:DeployIisAppPath="Default Web Site" /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\ /t:Package artifacts: files: - '**/' discard-paths: no base-directory: 'C:\codebuild\artifacts_PublishedWebsites${env:PROJECT}_Package\Archive'*
- CodeBuild project was created using below link for custom environments -
When running the msbuild command using my local machine, the package compiles without issues.
When running on CodeBuild using custom docker image build using instructions on link on step 2 it throws below errors -
C:\codebuild\tmp\output\src102630403\src\TriyoCore.DAL\TriyoCore.DAL.csproj" (default target) (2:2) ->
(CoreCompile target) ->
Repositories\BaseRepository.cs(25,24): error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference? [C:\codebuild\tmp\output\src102630403\src\TriyoCore.DAL\TriyoCore.DAL.csproj]
Repositories\BaseRepository.cs(25,24): error CS8356: Predefined type 'System.ValueTuple2' is declared in multiple referenced assemblies: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [C:\codebuild\tmp\output\src102630403\src\TriyoCore.DAL\TriyoCore.DAL.csproj] Repositories\IBaseRepository.cs(8,9): error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference? [C:\codebuild\tmp\output\src102630403\src\TriyoCore.DAL\TriyoCore.DAL.csproj] Repositories\IBaseRepository.cs(8,9): error CS8356: Predefined type 'System.ValueTuple
2' is declared in multiple referenced assemblies: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [C:\codebuild\tmp\output\src102630403\src\TriyoCore.DAL\TriyoCore.DAL.csproj]
1 Warning(s)
4 Error(s)
Time Elapsed 00:00:08.10
[Container] 2021/06/30 11:54:25 Command did not exit successfully msbuild $env:TriyoCore.API.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:DeployIisAppPath="Default Web Site" /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\ /t:Package exit status 1
[Container] 2021/06/30 11:54:26 Phase complete: BUILD State: FAILED
[Container] 2021/06/30 11:54:26 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: msbuild $env:TriyoCore.API.csproj /p:TargetFrameworkVersion=v$env:DOTNET_FRAMEWORK /p:Configuration=Release /p:DeployIisAppPath="Default Web Site" /p:PackageAsSingleFile=false /p:OutDir=C:\codebuild\artifacts\ /t:Package. Reason: exit status 1