diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
index 2e84fd51ab..42196852a8 100644
--- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
+++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
@@ -32,7 +32,13 @@
+
+#include
+#include
+
+
+#define ORT_ABORT_ON_ERROR(expr) \
+ do { \
+ OrtStatus* onnx_status = (expr); \
+ if (onnx_status != NULL) { \
+ const char* msg = OrtGetErrorMessage(onnx_status); \
+ fprintf(stderr, "%s\n", msg); \
+ OrtReleaseStatus(onnx_status); \
+ abort(); \
+ } \
+ } while (0);
+
+using namespace Microsoft::VisualStudio::CppUnitTestFramework;
+
+namespace UnitTest1
+{
+ TEST_CLASS(UnitTest1)
+ {
+ public:
+
+ int run_inference(OrtSession* session) {
+ size_t input_height = 224;
+ size_t input_width = 224;
+ float* model_input = (float *) malloc (sizeof (float) * 224 * 224 * 3);
+ size_t model_input_ele_count = 224 * 224 * 3;
+
+ // initialize to values between 0.0 and 1.0
+ for (unsigned int i = 0; i < model_input_ele_count; i++)
+ model_input[i] = (float)i / (float)(model_input_ele_count + 1);
+
+ OrtAllocatorInfo* allocator_info;
+ ORT_ABORT_ON_ERROR(OrtCreateCpuAllocatorInfo(OrtArenaAllocator, OrtMemTypeDefault, &allocator_info));
+ const size_t input_shape[] = { 1, 3, 224, 224 };
+ const size_t input_shape_len = sizeof(input_shape) / sizeof(input_shape[0]);
+ const size_t model_input_len = model_input_ele_count * sizeof(float);
+
+ OrtValue* input_tensor = NULL;
+ ORT_ABORT_ON_ERROR(OrtCreateTensorWithDataAsOrtValue(allocator_info, model_input, model_input_len, input_shape, input_shape_len, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, &input_tensor));
+ assert(input_tensor != NULL);
+ assert(OrtIsTensor(input_tensor));
+ OrtReleaseAllocatorInfo(allocator_info);
+ const char* input_names[] = { "data_0" };
+ const char* output_names[] = { "softmaxout_1" };
+ OrtValue* output_tensor = NULL;
+ ORT_ABORT_ON_ERROR(OrtRun(session, NULL, input_names, (const OrtValue* const*)&input_tensor, 1, output_names, 1, &output_tensor));
+ assert(output_tensor != NULL);
+ assert(OrtIsTensor(output_tensor));
+
+ OrtReleaseValue(output_tensor);
+ OrtReleaseValue(input_tensor);
+ free(model_input);
+ return 0;
+ }
+
+ int test()
+ {
+ const wchar_t * model_path = L"squeezenet.onnx";
+ OrtEnv* env;
+ ORT_ABORT_ON_ERROR(OrtCreateEnv(ORT_LOGGING_LEVEL_WARNING, "test", &env));
+ OrtSessionOptions* session_option = OrtCreateSessionOptions();
+ OrtSession* session;
+ ORT_ABORT_ON_ERROR(OrtCreateSession(env, model_path, session_option, &session));
+
+ OrtSetSessionThreadPoolSize(session_option, 1);
+ //return run_inference(session);
+ return 0;
+ }
+
+ TEST_METHOD(TestMethod1)
+ {
+ int res = test();
+ Assert::AreEqual(res, 0);
+ }
+ };
+}
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.vcxproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.vcxproj
new file mode 100644
index 0000000000..396862a7bf
--- /dev/null
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.vcxproj
@@ -0,0 +1,111 @@
+
+
+
+ $(MSBuildThisFileDirectory)..\..
+ D:\onnxruntime\csharp
+
+
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 15.0
+ {2FF16D63-26BD-429A-9B94-862418408E27}
+ Win32Proj
+ Microsoft.ML.OnnxRuntime.EndToEndTests.Capi
+ 10.0.17763.0
+ NativeUnitTestProject
+
+
+
+ DynamicLibrary
+ true
+ v141
+ Unicode
+ false
+
+
+ DynamicLibrary
+ false
+ v141
+ true
+ Unicode
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+
+ Level3
+ Disabled
+ $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
+ _DEBUG;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
+ NDEBUG;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+ true
+ $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
+
+
+
+
+
+
+
+ Always
+ false
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
\ No newline at end of file
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf
new file mode 100644
index 0000000000..e9a91f917d
--- /dev/null
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat
new file mode 100644
index 0000000000..0ba3984799
--- /dev/null
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat
@@ -0,0 +1,60 @@
+REM Copyright (c) Microsoft Corporation. All rights reserved.
+REM Licensed under the MIT License.
+echo on
+
+set LocalNuGetRepo=%1
+setlocal enableextensions disabledelayedexpansion
+
+REM WorkingDirectory is Build.SourcesDirectory\csharp
+set /p MajorVersionNumber=<..\VERSION_NUMBER
+set VersionSuffix=
+IF NOT DEFINED IsReleaseBuild (
+ FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO (
+ set VersionSuffix=-dev-%%F
+ )
+)
+
+set CurrentOnnxRuntimeVersion=%MajorVersionNumber%%VersionSuffix%
+@echo %CurrentOnnxRuntimeVersion%
+
+pushd test\Microsoft.ML.OnnxRuntime.EndToEndTests.Capi
+
+REM Set up VS envvars
+REM call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
+
+REM Generate packages.config with version
+echo off
+set "token=CurrentOnnxRuntimeVersion"
+set "replace=%CurrentOnnxRuntimeVersion%"
+set "templateFile=packages.conf"
+for /f "delims=" %%i in ('type "%templateFile%" ^& break ^> "packages.config" ') do (
+ set "line=%%i"
+ setlocal enabledelayedexpansion
+ >>"packages.config" echo(!line:%token%=%replace%!
+ endlocal
+)
+echo on
+
+REM Restore NuGet Packages
+nuget restore -PackagesDirectory ..\packages -Source %LocalNuGetRepo% Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.vcxproj
+if NOT %ERRORLEVEL% EQU 0 (
+ echo "Error:Nuget restore failed"
+ EXIT /B 1
+)
+
+REM Build Native project
+msbuild Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.vcxproj
+if NOT %ERRORLEVEL% EQU 0 (
+ echo "Error:MSBuild failed to compile project"
+ EXIT /B 1
+)
+
+
+REM Run Unit Tests
+vstest.console.exe /platform:x64 x64\debug\Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.dll
+if NOT %ERRORLEVEL% EQU 0 (
+ echo "Unit test failure: %ERRORLEVEL%"
+)
+
+popd
+EXIT /B 0
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj
index 12d3535138..8abdfe35a6 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj
@@ -30,12 +30,13 @@
false
-
- Always
- false
-
+
+
+
+
+