使用TFS 2013构建Visual Studio 2015解决方案时出现问题

时间:2015-08-19 16:45:49

标签: visual-studio-2015

我们有Visual Studio 2015 Enterprise RTM和针对beta 6 DNX SDK编译的MVC6 WebAPI预览项目。

现在我们想在TFS 2013服务器上构建这个项目。不幸的是构建失败了,因为(我们认为)beta 6软件包没有被恢复:

  

无法解析依赖关系Microsoft.AspNet.Mvc 6.0.0-beta6
  无法解析依赖Microsoft.AspNet.Server.IIS 1.0.0-beta6
  无法解析依赖关系Microsoft.AspNet.Server.WebListener 1.0.0-beta6
  无法解析依赖关系Microsoft.AspNet.StaticFiles 1.0.0-beta6
  无法解析依赖关系System.IdentityModel.Tokens 5.0.0-beta6-207211625
  无法解析依赖关系Microsoft.AspNet.Authentication.OAuthBearer 1.0.0-beta6

我们甚至不会在NuGet包恢复中看到构建日志中的任何尝试。

请考虑以下步骤重现:

  • 我们在构建服务器上安装了Visual Studio 2015 Enterprise RTM(我们需要完整的Visual Studio,因为我们在单元测试中使用了伪装),以构建代理程序登录并配置了Visual Studio的TFS源代码管理设置,确保选中自动NuGet还原,确保安装了Visual Studio beta 6 SDK工具并安装了beta 6 DNX(la' dnvm upgrade'命令)。

  • 接下来,我们使用TfvcTemplate.12.xaml模板在TFS中创建了一个新版本,指定了' /p:VisualStudioVersion=14.0'按照this article

  • 中的说明启用Advanced-> MSBuild参数
  • 最后,当我们对构建进行排队时,构建将失败并显示此日志:

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]
  • 最后一个难题是我们可以使用构建代理凭据远程访问TFS服务器。在Visual Studio 2015 Enterprise RTM中打开项目并构建它没有问题。显然,这与MSBuild和Visual Studio之间的分离有关,但我们并不了解细微差别。

像往常一样,我确信我们错过了秘密酱中的关键步骤,任何建议都会受到赞赏。

1 个答案:

答案 0 :(得分:2)

原来有更多的秘密酱。 This article解释了要做什么 - 我们需要引导DNX环境并运行DNU来获取包。

总之,最后的步骤是:

  • 向项目添加一个powershell脚本,我称之为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 }
  • 在TFS构建定义中,将此脚本添加到Process..Advanced ...预构建脚本路径下的“预构建脚本路径”,例如:
$/FunProjects/SPAFoundation/InitializeDNXEnvironment.ps1