I have an application built with .NET Core 1.0.1 - VS 2015 Tooling Preview 2 (using Visual Studio Update 3). I also have a test project for it, using MS tests, which I have built according to this guide: https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test.
The solution consists of two projects, one is the ASP.NET WebApi controller and the other is the associated test project.
My goal is to set up automatic build, test and deployment to Azure in Visual Studio Team Services (was Visual Studio Online).
I have set up the automated build following this guide: https://www.visualstudio.com/en-gb/docs/build/get-started/dot-net . The guide offers two options, and I have tried both:
- using a Visual Studio Solution step, which builds the .sln
- or command line steps compiling individual projects (running
dotnet build
in each project root).
The build solution step managed to pass successfully after I changed my global.json sdk version from 1.0.0-preview2-003131
to 1.0.0-preview2-003121
. However, running individual dotnet build
for each project works with 003131 as well.
For running the tests I have a command line step that calls dotnet test
. This one does not pass, please see below the error message:
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.
So looks like I don't have the proper version of ASP.NET SDK on the hosted agent in VSTS. However, I do have a few questions:
- Why is the build successful but running the tests fails? Shouldn't the build fail at compile time because of the missing framework version as well? Seems like the problem is detected at run time only, when invoking the tests, but why?
- Why do the individual project builds pass when using 1.0.0-preview2-003131 but the solution build does not?
- Apparently the hosted agent has ".NET Core 1.0 with Preview 2 Tooling", according to https://www.visualstudio.com/en-us/docs/build/admin/agents/hosted-pool#software. I'm happy to downgrade my code to use that, but where do I find it? All the download sources I have found (official http://dot.net page, MSDN links) are for 1.0.1 and 1.0 preview 2 is nowhere to be found.
Thank you.
I have included below the global.json and the project.json files from the two projects, in case they could help.
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}
project.json for the WebApi project
{
"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 from the test project
{
"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"
]
}
}
}