2
votes

We have Visual Studio 2015 Enterprise RTM and an MVC6 WebAPI preview project compiling against the beta 6 DNX SDK.

Now we want to build this project on our TFS 2013 server. Unfortunate the build fails because (we think) the beta 6 packages are not being restored:

Unable to resolve dependency Microsoft.AspNet.Mvc 6.0.0-beta6
Unable to resolve dependency Microsoft.AspNet.Server.IIS 1.0.0-beta6
Unable to resolve dependency Microsoft.AspNet.Server.WebListener 1.0.0-beta6
Unable to resolve dependency Microsoft.AspNet.StaticFiles 1.0.0-beta6
Unable to resolve dependency System.IdentityModel.Tokens 5.0.0-beta6-207211625
Unable to resolve dependency Microsoft.AspNet.Authentication.OAuthBearer 1.0.0-beta6

We don't even see any attempt in the build log at a NuGet package restore.

Consider the following steps to reproduce:

  • We installed Visual Studio 2015 Enterprise RTM on our build server (we need full-up Visual Studio because we use fakes in the unit tests), logged in as the build agent and configured Visual Studio's TFS source control settings, made sure Automatic NuGet restore is checked, ensured that the Visual Studio beta 6 SDK tooling is installed and that the beta 6 DNX is installed (a la 'dnvm upgrade' command).

  • Next we created a new build in TFS using the TfvcTemplate.12.xaml template, specifying the ' /p:VisualStudioVersion=14.0 ' switch on the Advanced->MSBuild argument as specified in this article.

  • Finally when we queue a build the build fails with this log:

Build started 8/19/2015 8:51:09 AM.
     1>Project "C:\Builds\12\FunProjects\SPAFoundation\src\SPAFoundation.sln" on node 1 (default targets).
     1>ValidateSolutionConfiguration:
         Building solution configuration "Release|Any CPU".
     1>Project "C:\Builds\12\FunProjects\SPAFoundation\src\SPAFoundation.sln" (1) is building "C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj" (2) on node 1 (default targets).
     2>PrepareForBuild:
         Creating directory "..\..\artifacts\obj\API\Release\".
       PreComputeCompileTypeScript:
         C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\tsc.exe --noEmitOnError  COMPUTE_PATHS_ONLY
       CompileTypeScript:
         C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.5\tsc.exe --noEmitOnError 
       CoreCompile:
         C:\Users\svctfsserver\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe --appbase "C:\Builds\12\FunProjects\SPAFoundation\src\src\API" "C:\Users\svctfsserver\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\lib\Microsoft.Framework.PackageManager\Microsoft.Framework.PackageManager.dll" pack "C:\Builds\12\FunProjects\SPAFoundation\src\src\API" --configuration Release --out "C:\Builds\12\FunProjects\SPAFoundation\bin"
         Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256
         Building API for DNX,Version=v4.5.1
           Using Project dependency API 1.0.0
             Source: C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json
           Unable to resolve dependency Microsoft.AspNet.Mvc 6.0.0-beta6
           Unable to resolve dependency Microsoft.AspNet.Server.IIS 1.0.0-beta6
           Unable to resolve dependency Microsoft.AspNet.Server.WebListener 1.0.0-beta6
           Unable to resolve dependency Microsoft.AspNet.StaticFiles 1.0.0-beta6
           Unable to resolve dependency System.IdentityModel.Tokens 5.0.0-beta6-207211625
           Unable to resolve dependency Microsoft.AspNet.Authentication.OAuthBearer 1.0.0-beta6
           Unable to resolve dependency Serilog.Framework.Logging 1.0.0-beta-43
           Unable to resolve dependency Unity 3.5.1404
.
.
.
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(6,29): error : The dependency Microsoft.AspNet.Mvc >= 6.0.0-beta6 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(7,36): error : The dependency Microsoft.AspNet.Server.IIS >= 1.0.0-beta6 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(8,44): error : The dependency Microsoft.AspNet.Server.WebListener >= 1.0.0-beta6 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(9,37): error : The dependency Microsoft.AspNet.StaticFiles >= 1.0.0-beta6 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(10,36): error : The dependency System.IdentityModel.Tokens >= 5.0.0-beta6-207211625 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
         C:\Builds\12\FunProjects\SPAFoundation\src\src\API\project.json(11,52): error : The dependency Microsoft.AspNet.Authentication.OAuthBearer >= 1.0.0-beta6 could not be resolved. [C:\Builds\12\FunProjects\SPAFoundation\src\src\API\API.xproj]
  • The last piece of the puzzle is we can remote into the TFS server using the build agent credentials. open the project in Visual Studio 2015 Enterprise RTM and build it without issue. Clearly this is related to the separation between MSBuild and Visual Studio but we don't understand the nuance.

As usual I'm sure we're missing a key step in the secret sauce, any advice would be appreciated.

1

1 Answers

2
votes

Turns out there is more secret sauce. This article explains what to do exactly - we needed to bootstrap the DNX environment and run DNU to fetch packages.

In summary the final steps were:

  • Add a powershell script to the project, I called mine InitializeDNXEnvironment.ps1, as described here:
# bootstrap DNVM into this session.
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}

# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore

if($globalJson)
{
    $dnxVersion = $globalJson.sdk.version
}
else
{
    Write-Warning "Unable to locate global.json to determine using 'latest'"
    $dnxVersion = "latest"
}

# install DNX
# only installs the default (x86, clr) runtime of the framework.
# If you need additional architectures or runtimes you should add additional calls
# ex: & $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent

 # run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }
  • In the TFS build definition, add this script to the "Pre-build script path" under Process..Advanced...Pre-build script path, for example:
$/FunProjects/SPAFoundation/InitializeDNXEnvironment.ps1