I created a VS 2015 U3 solution that contains a netstandard1.3 PCL library X and a netcoreapp1.0 test library Y. I'm using MSTest (dotnet-test-mstest and MSTest.TestFramework).
This is src\X\project.json:
{
"supports": {},
"dependencies": {
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.3": {}
}
}
This is test\Y\project.json:
{
"version": "1.0.0-*",
"testRunner": "mstest",
"dependencies": {
"Microsoft.NETCore.App": "1.0.0",
"dotnet-test-mstest": "1.0.1-preview",
"MSTest.TestFramework": "1.0.0-preview",
"X": { "target": "project" }
},
"frameworks": {
"netcoreapp1.0": {
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"runtimes": {
"win8-x64": {}
}
}
It turned out that I need to have this last
"runtimes": {
"win8-x64": {}
}
in Y\project.json, otherwise I get the following error:
_dotnet-test Error: 0 : System.InvalidOperationException: Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win81-x64, win8-x64, win7-x64'._
Why is that? Can't I have a generic test app that will work everywhere if I install the SDK?
Related
I get the following error when trying to connect to my SQL Server Express RDS instance over AWS Lambda using System.Data.SqlClient:
"errorType": "PlatformNotSupportedException",
"errorMessage": "Operation is not supported on this platform.",
"stackTrace": [
"at System.Runtime.InteropServices.OSPlatform.get_Windows()",
"at System.Data.SqlClient.SNI.SNITCPHandle.d__22.MoveNext()"
]
I build the deploy package using Amazon.Lambda.Tools. Running the function and connecting to the database from local works fine, but fails when trying to run it on AWS Lambda.
Here is my project.json:
{
"version": "1.0.0-*",
"description": "AWS lambda Console Application",
"authors": [ "" ],
"packOptions": {
"tags": [],
"projectUrl": "",
"licenseUrl": ""
},
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Newtonsoft.Json": "9.0.1",
"Amazon.Lambda.Core": "1.0.0*",
"Amazon.Lambda.Serialization.Json": "1.0.1",
"Amazon.Lambda.Tools": {
"type": "build",
"version": "1.0.0-preview1"
},
"Dapper": "1.50.2",
"System.Data.SqlClient": "4.3.0"
},
"tools": {
"Amazon.Lambda.Tools": "1.0.0-preview1"
},
"commands": {
"AwsLambda": "run"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
Had the same problem and for me just changing
"System.Data.SqlClient": "4.3.0"
to
"System.Data.SqlClient": "4.1.0"
worked for me. I did not have to change the NetCore.App dependencies.
Explicitly add reference to
"System.Data.SqlClient": "4.1.0",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0"
solves the problem.
Can you try to change
"System.Data.SqlClient": "4.3.0"
to
"System.Data.SqlClient": "4.1.0"
and change
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
to
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
I'm trying to debug a NETCore project in VS Code but launching the debugger gives me the following error:
MSBUILD : error MSB4025: The project file could not be loaded.
Data at the root level is invalid. Line 1, position 1.
c:\path\to\my\project.json
project.json content:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
}
}
Any ideas?
Turned out that the project.json format is not longer supported. More info here on GitHub.
I start writing project on asp.net core and I can not find class ByteRangeStreamContent.
Where is it?
Did it was removed from asp.net core?
Is there replacement of this class?
UPDATE 2016-10-06
dotnet --version
1.0.0-preview2-003131
Instead of using ByteRangeStreamContent you can now use the FileStreamResult or FileContentResult and set EnableRangeProcessing to true.
new FileStreamResult(new MemoryStream(bytes), new MediaTypeHeaderValue("audio/mp3"))
{
EnableRangeProcessing = true
};
Add this dependency in your project.json:
"Microsoft.AspNet.WebApi.Client": "5.2.2"
Then, you can use the class:
System.Net.Http.ByteRangeStreamContent
Another option is to write ByteRangeStreamContent to import automatically using Visual Studio:
My project.json is (the default when creating a new web api project):
{
"dependencies": {
"Microsoft.AspNet.WebApi.Client": "5.2.2",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"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"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net461": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
My dotnet version is the following:
C:\Users\fabriciopombo>dotnet --version
1.0.0-preview2-003121
And I'm using Visual Studio 2015 Update 3
I created an empty asp.net web application project with rc2. My project file is:
{
"testRunner": "xunit",
"dependencies": {
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-rc2-build10025",
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.Cors": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
Now I want to add HttpConfiguration config = new HttpConfiguration(); in my unit test.
But HtppConfiguration is from ASP.NET WEB API 2. How to change my project.json file? Or is there any replacement for it in ASP.NET CORE RC2?
ASP.Core provides an easy way for integration testing using TestServer class. The following may help to start using it:
an ASP.Net Core documentation about integration testing.
a post about using TestServer with example on github.
a TestServerTests.cs file from Hosting repo, that contains xunit tests for TestServer. May help to review, what TestServer can do.
good question on SO: "Why the TestServer (AspNetCore) gives 404 error on static files?"
and keep in mind that a lot of projects in https://github.com/aspnet use TestServer for testing (like Diagnostics ).
I have ASP.NET Core project which has both netcoreapp and net46 in frameworks section. I can build and run it without any problem on Mac OS X. But when i open it in VSCode it shows tons of errors like this: Predefined type '...' is not defined or imported [net46] and everything is red.
Is there any way to fix it without removing net46 from project.json?
Frameworks section of my project.json:
"frameworks": {
"net46": {
"dependencies": {
"System.Net.Http": "4.0.0-*"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
},
"System.Net.Http": "4.0.1-*"
},
"imports": [
"dnxcore50"
]
}
}