0
votes

I set up CI for my ASP.NET Core 1.1 project which uses Azure AD B2C (from this example - https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp). So here's what I have in .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <PreserveCompilationContext>true</PreserveCompilationContext>
  </PropertyGroup>

  <PropertyGroup>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
...
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="BuildWebCompiler" Version="1.11.326" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
    <PackageReference Include="Microsoft.Identity.Client" Version="1.1.0-preview" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
  </ItemGroup>

</Project>

When I go to VSTS I see the following log with errors:


Starting: Build

******************************************************************************

Task : .NET Core Description : Build, test and publish using dotnet core command-line. Version : 1.0.2 Author : Microsoft Corporation

Help : More Information

"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\MMLServices\MMLServices.csproj --configuration release Microsoft (R) Build Engine version 15.1.1012.6693 Copyright (C) Microsoft Corporation. All rights reserved.

C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9): error MSB4062: The "WebCompiler.CompilerBuildTask" task could not be loaded from the assembly C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\MMLServices\MMLServices.csproj]

Build FAILED.

C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9): error MSB4062: The "WebCompiler.CompilerBuildTask" task could not be loaded from the assembly C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\MMLServices\MMLServices.csproj] 0 Warning(s) 1 Error(s)

Time Elapsed 00:00:03.66 Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1 Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\MMLServices\MMLServices.csproj

So, how can I fix this?

UPDATE:

I added debug=true, here's the log after that (Publish task):

2017-06-20T15:23:36.6048010Z [command]"C:\Program Files\dotnet\dotnet.exe" publish d:\a\1\s\MMLServices\MMLServices.csproj --configuration release --output d:\a\1\a\MMLServices 2017-06-20T15:23:36.7748032Z Microsoft (R) Build Engine version 15.1.1012.6693 2017-06-20T15:23:36.7758030Z Copyright (C) Microsoft Corporation. All rights reserved. 2017-06-20T15:23:36.7758030Z 2017-06-20T15:23:37.3732835Z C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build\BuildWebCompiler.targets(15,9): error MSB4062: The "WebCompiler.CompilerBuildTask" task could not be loaded from the assembly C:\Users\buildguest.nuget\packages\buildwebcompiler\1.11.326\build..\tools\WebCompiler.exe. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [d:\a\1\s\MMLServices\MMLServices.csproj] 2017-06-20T15:23:37.3943585Z ##[debug]rc:1 2017-06-20T15:23:37.3943585Z ##[debug]success:false 2017-06-20T15:23:37.3973597Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1 2017-06-20T15:23:37.3973597Z ##[debug]Processed: ##vso[task.issue type=error;]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1 2017-06-20T15:23:37.4003593Z ##[debug]task result: Failed 2017-06-20T15:23:37.4003593Z ##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4003593Z ##[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4034692Z ##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\MMLServices\MMLServices.csproj 2017-06-20T15:23:37.4073330Z ##[section]Finishing: Publish

2

2 Answers

0
votes

The issue is related do donet build with BuildWebCompiler package. You can use Visual Studio Build task instead:

  1. Remove .NET Core Build task
  2. Add Visual Studio build task (Solution: ***.sln; Visual Studio Version: Visual Studio 2017)

Update:

Regarding publish, you can refer to these steps (can’t use dotnet publish):

  1. Create a web deploy package publish profile in Visual Studio and add to source control

Sample:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>Package</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <PublishFramework>netcoreapp1.1</PublishFramework>
    <ProjectGuid>6ecb453c-aea3-44af-8185-059fbac7b56c</ProjectGuid>
    <DesktopBuildPackageLocation>E:\yy\WebApp-OpenIDConnect-DotNet.zip</DesktopBuildPackageLocation>
    <PackageAsSingleFile>true</PackageAsSingleFile>
    <DeployIisAppPath>Default Web Site/tt</DeployIisAppPath>
    <PublishDatabaseSettings>
      <Objects xmlns="" />
    </PublishDatabaseSettings>
  </PropertyGroup>
</Project>
  1. Remove .NET Core tasks (e.g. publish, build)
  2. Specify this MSBuild Arguments for Visual Studio Build task

:

/p:DeployOnBuild=true /p:PublishProfile=[publish profile];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp-OpenIDConnect-DotNet.zip"
0
votes

ok, I removed that Build definition and added a new one - this time with ASP.NET Core (.NET Framework) template and everything worked.