我有一个使用.NET Core 1.0.1构建的应用程序 - VS 2015 Tooling Preview 2(使用Visual Studio Update 3)。我也有一个测试项目,使用我根据本指南构建的MS测试:https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test。
该解决方案由两个项目组成,一个是ASP.NET WebApi控制器,另一个是关联的测试项目。
我的目标是在Visual Studio Team Services(Visual Studio Online)中为Azure设置自动构建,测试和部署。
我已根据本指南设置了自动构建:https://www.visualstudio.com/en-gb/docs/build/get-started/dot-net。该指南提供了两种选择,我尝试过两种方法:
dotnet build
)。 在将global.json sdk版本从1.0.0-preview2-003131
更改为1.0.0-preview2-003121
后,构建解决方案步骤成功通过。但是,为每个项目运行单个dotnet build
也可以使用003131。
为了运行测试,我有一个调用dotnet test
的命令行步骤。这个没有通过,请参阅下面的错误消息:
2016-09-16T18:46:40.2293724Z The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found.
2016-09-16T18:46:40.2293724Z - Check application dependencies and target a framework version installed at:
2016-09-16T18:46:40.2293724Z C:\Program Files\dotnet\shared\Microsoft.NETCore.App
2016-09-16T18:46:40.2293724Z - The following versions are installed:
2016-09-16T18:46:40.2293724Z 1.0.0
2016-09-16T18:46:40.2293724Z 1.0.0-rc2-3002702
2016-09-16T18:46:40.2293724Z - Alternatively, install the framework version '1.0.1'.
2016-09-16T18:46:40.2303741Z SUMMARY: Total: 1 targets, Passed: 0, Failed: 1.
2016-09-16T18:46:40.2593745Z ##[error]Process completed with exit code -2147450749.
看起来我在VSTS中的托管代理上没有正确版本的ASP.NET SDK。但是,我确实有几个问题:
谢谢。
我在下面列出了来自两个项目的global.json和project.json文件,以防它们可以提供帮助。
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
Project.json用于WebApi项目
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Swashbuckle": "6.0.0-beta901",
"Swashbuckle.SwaggerGen": "6.0.0-beta901",
"Swashbuckle.SwaggerUi": "6.0.0-beta901"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"xmlDoc": true,
"nowarn": [ "1591" ]
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
来自测试项目的project.json
{
"version": "1.0.0-*",
"testRunner": "mstest",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"dotnet-test-mstest": "1.1.1-preview",
"MSTest.TestFramework": "1.0.3-preview",
"WebApiCoreMock": {
"target": "project"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
}
}
答案 0 :(得分:0)
看起来我能够回答我自己的问题,我已经取代了:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
带
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
现在dotnet test
步过了。
由于我仍不确定解决方案构建步骤与单个dotnet build
命令实际发生了什么,我将打开问题。