在 visual studio team services 托管构建代理上的 .net v5.4 项目中构建 dapper 时出错
Error building dapper in a .net v5.4 project on visual studio team services hosted build agent
我最近建立了一个非常基本的 .net web 项目,并在我的存储库中使用了 dapper 来访问数据库。它在我的本地计算机上运行和构建时没有错误,但是当我尝试在 VSTS 上构建时,我收到一条错误消息,指出某些包与 .net 框架 v5.4 或 v5.0 不兼容(尝试了几个不同的框架尝试构建它。)
这是包含 dapper 的相关 project.json 文件。这在我的计算机上本地构建和恢复没有任何问题:
{
"version": "1.0.0-*",
"description": "ProjectPOC.Core.Implementations Class Library",
"authors": [ "CBergeron" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"ProjectPOC.Core.Infrastructure": "",
"ProjectPOC.Core.Models": "",
"Microsoft.Extensions.OptionsModel": "1.0.0-rc1-final",
"Dapper": "1.50.0-beta9"
},
"frameworks": {
"net451": {
"dependencies": {
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
当此项目构建在 VSTS 托管构建代理上时,我正在 运行 预安装。ps1 此处常用的脚本:
# bootstrap DNVM into this session.
"bootstrapping dnvminstall..."
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
"finished bootstrapping"
"Loading global.json"
# 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
"finished loading global.json"
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
"setting DNX version.. to $dnxVersion "
}
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
"installing DNX"
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent
#& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r clr
#& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
#& $env:USERPROFILE\.dnx\bin\dnvm use $dnxVersion
& $env:USERPROFILE\.dnx\bin\dnvm list
"finished DNX install "
"DNU restoring....."
# 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\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }
#dnu restore
"finsihed DNU restore"
此脚本正在根据构建日志安装以下 dnx,它与我在本地计算机上列出的 dnvm 相匹配:
2016-05-19T03:45:19.1014995Z installing DNX
2016-05-19T03:45:19.9042850Z Downloading dnx-clr-win-x86.1.0.0-rc1-update2 from https://www.nuget.org/api/v2
2016-05-19T03:45:22.7176602Z Installing to C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2
2016-05-19T03:45:22.7766619Z Adding C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin to process PATH
2016-05-19T03:45:22.8456619Z Adding C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin to user PATH
2016-05-19T03:45:22.8826599Z Native image generation (ngen) is skipped. Include -Ngen switch to turn on native image generation to improve application startup time.
2016-05-19T03:45:23.0276682Z Active Version Runtime Architecture OperatingSystem Alias
2016-05-19T03:45:23.0346603Z ------ ------- ------- ------------ --------------- -----
2016-05-19T03:45:23.0356615Z * 1.0.0-rc1-update2 clr x86 win
2016-05-19T03:45:23.0586614Z finished DNX install
2016-05-19T03:45:23.0596622Z DNU restoring.....
2016-05-19T03:45:23.2796607Z Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16609
2016-05-19T03:45:23.4785866Z GET https://api.nuget.org/v3/index.json
2016-05-19T03:45:23.5821917Z OK https://api.nuget.org/v3/index.json 123ms
2016-05-19T03:45:23.6261910Z GET https://www.myget.org/F/aspnetvnext/api/v2/
2016-05-19T03:45:24.4737562Z OK https://www.myget.org/F/aspnetvnext/api/v2/ 847ms
2016-05-19T03:45:24.4787560Z GET https://www.myget.org/F/aspnetmaster/
2016-05-19T03:45:25.1793928Z OK https://www.myget.org/F/aspnetmaster/ 700ms
完成从 nuget 的恢复后,在构建过程中,它会为包含 dapper 的包库以及引用它的任何内容抛出这样的错误:
Unable to resolve dependency System.Collections.NonGeneric 4.0.1-rc2-24027
...
2016-05-19T03:47:01.3562201Z ##[error]Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\project.json(0,0): Error NU1002: The dependency System.Collections.NonGeneric 4.0.1-rc2-24027 in project ProjectPOC.Core.Implementations does not support framework .NETPlatform,Version=v5.4.
2016-05-19T03:47:01.3602187Z 5>C:\a\s\Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\project.json : error NU1002: The dependency System.Collections.NonGeneric 4.0.1-rc2-24027 in project ProjectPOC.Core.Implementations does not support framework .NETPlatform,Version=v5.4. [C:\a\s\Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\ProjectPOC.Core.Implementations.xproj]
同样,这是在 VS2015 中从我的本地机器上完美地构建、运行ning、部署到 azure 等,所以我觉得它与托管构建代理有关,它是 dnx/dnvm/nuget 设置。是否有什么我需要添加到构建代理或我需要对 dnvm/nuget 安装做些什么才能获得正确版本的一切?我还将我的 nuget.config 上传到构建代理,但这也没有帮助。我可以根据要求提供更多日志。
我的本地 dnvm 列表如下所示:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta8 clr x64 win
1.0.0-beta8 coreclr x64 win
1.0.0-beta8 coreclr x86 win
1.0.0-rc1-update1 clr x64 win
1.0.0-rc1-update1 clr x86 win
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
* 1.0.0-rc1-update2 clr x86 win default
如果有人可以提供任何帮助或在使用新的 .net 之前运行遇到过类似问题,请提前致谢
我以前遇到过这个问题,但它在我的本地机器上不起作用。我通过为 Dapper 使用“1.50.0-beta8”版本而不是“1.50.0-beta9”来让它工作。 beta8 使用比 beta9 更旧的依赖项。
这个问题好像是这里的改动引起的:Rename "dotnet" to "NETStandard"但是我还没来得及弄清楚。
我最近建立了一个非常基本的 .net web 项目,并在我的存储库中使用了 dapper 来访问数据库。它在我的本地计算机上运行和构建时没有错误,但是当我尝试在 VSTS 上构建时,我收到一条错误消息,指出某些包与 .net 框架 v5.4 或 v5.0 不兼容(尝试了几个不同的框架尝试构建它。)
这是包含 dapper 的相关 project.json 文件。这在我的计算机上本地构建和恢复没有任何问题:
{
"version": "1.0.0-*",
"description": "ProjectPOC.Core.Implementations Class Library",
"authors": [ "CBergeron" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"ProjectPOC.Core.Infrastructure": "",
"ProjectPOC.Core.Models": "",
"Microsoft.Extensions.OptionsModel": "1.0.0-rc1-final",
"Dapper": "1.50.0-beta9"
},
"frameworks": {
"net451": {
"dependencies": {
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
}
当此项目构建在 VSTS 托管构建代理上时,我正在 运行 预安装。ps1 此处常用的脚本:
# bootstrap DNVM into this session.
"bootstrapping dnvminstall..."
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
"finished bootstrapping"
"Loading global.json"
# 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
"finished loading global.json"
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
"setting DNX version.. to $dnxVersion "
}
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
"installing DNX"
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent
#& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r clr
#& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
#& $env:USERPROFILE\.dnx\bin\dnvm use $dnxVersion
& $env:USERPROFILE\.dnx\bin\dnvm list
"finished DNX install "
"DNU restoring....."
# 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\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }
#dnu restore
"finsihed DNU restore"
此脚本正在根据构建日志安装以下 dnx,它与我在本地计算机上列出的 dnvm 相匹配:
2016-05-19T03:45:19.1014995Z installing DNX
2016-05-19T03:45:19.9042850Z Downloading dnx-clr-win-x86.1.0.0-rc1-update2 from https://www.nuget.org/api/v2
2016-05-19T03:45:22.7176602Z Installing to C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2
2016-05-19T03:45:22.7766619Z Adding C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin to process PATH
2016-05-19T03:45:22.8456619Z Adding C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin to user PATH
2016-05-19T03:45:22.8826599Z Native image generation (ngen) is skipped. Include -Ngen switch to turn on native image generation to improve application startup time.
2016-05-19T03:45:23.0276682Z Active Version Runtime Architecture OperatingSystem Alias
2016-05-19T03:45:23.0346603Z ------ ------- ------- ------------ --------------- -----
2016-05-19T03:45:23.0356615Z * 1.0.0-rc1-update2 clr x86 win
2016-05-19T03:45:23.0586614Z finished DNX install
2016-05-19T03:45:23.0596622Z DNU restoring.....
2016-05-19T03:45:23.2796607Z Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16609
2016-05-19T03:45:23.4785866Z GET https://api.nuget.org/v3/index.json
2016-05-19T03:45:23.5821917Z OK https://api.nuget.org/v3/index.json 123ms
2016-05-19T03:45:23.6261910Z GET https://www.myget.org/F/aspnetvnext/api/v2/
2016-05-19T03:45:24.4737562Z OK https://www.myget.org/F/aspnetvnext/api/v2/ 847ms
2016-05-19T03:45:24.4787560Z GET https://www.myget.org/F/aspnetmaster/
2016-05-19T03:45:25.1793928Z OK https://www.myget.org/F/aspnetmaster/ 700ms
完成从 nuget 的恢复后,在构建过程中,它会为包含 dapper 的包库以及引用它的任何内容抛出这样的错误:
Unable to resolve dependency System.Collections.NonGeneric 4.0.1-rc2-24027
...
2016-05-19T03:47:01.3562201Z ##[error]Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\project.json(0,0): Error NU1002: The dependency System.Collections.NonGeneric 4.0.1-rc2-24027 in project ProjectPOC.Core.Implementations does not support framework .NETPlatform,Version=v5.4.
2016-05-19T03:47:01.3602187Z 5>C:\a\s\Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\project.json : error NU1002: The dependency System.Collections.NonGeneric 4.0.1-rc2-24027 in project ProjectPOC.Core.Implementations does not support framework .NETPlatform,Version=v5.4. [C:\a\s\Platform\POC\ProjectPOC.Web.API\src\ProjectPOC.Core.Implementations\ProjectPOC.Core.Implementations.xproj]
同样,这是在 VS2015 中从我的本地机器上完美地构建、运行ning、部署到 azure 等,所以我觉得它与托管构建代理有关,它是 dnx/dnvm/nuget 设置。是否有什么我需要添加到构建代理或我需要对 dnvm/nuget 安装做些什么才能获得正确版本的一切?我还将我的 nuget.config 上传到构建代理,但这也没有帮助。我可以根据要求提供更多日志。
我的本地 dnvm 列表如下所示:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta8 clr x64 win
1.0.0-beta8 coreclr x64 win
1.0.0-beta8 coreclr x86 win
1.0.0-rc1-update1 clr x64 win
1.0.0-rc1-update1 clr x86 win
1.0.0-rc1-update1 coreclr x64 win
1.0.0-rc1-update1 coreclr x86 win
* 1.0.0-rc1-update2 clr x86 win default
如果有人可以提供任何帮助或在使用新的 .net 之前运行遇到过类似问题,请提前致谢
我以前遇到过这个问题,但它在我的本地机器上不起作用。我通过为 Dapper 使用“1.50.0-beta8”版本而不是“1.50.0-beta9”来让它工作。 beta8 使用比 beta9 更旧的依赖项。
这个问题好像是这里的改动引起的:Rename "dotnet" to "NETStandard"但是我还没来得及弄清楚。