diff --git a/cmake/onnxruntime_csharp.cmake b/cmake/onnxruntime_csharp.cmake
index ddd9628ed2..ca9fc9a357 100644
--- a/cmake/onnxruntime_csharp.cmake
+++ b/cmake/onnxruntime_csharp.cmake
@@ -10,3 +10,9 @@ include_external_msproject(${CSHARP_MASTER_TARGET}
${CSHARP_MASTER_PROJECT}
onnxruntime # make it depend on the native onnxruntime project
)
+
+# generate Directory.Build.props
+set(DIRECTORY_BUILD_PROPS_COMMENT "WARNING: This is a generated file, please do not check it in!")
+configure_file(${CSHARP_ROOT}/Directory.Build.props.in
+ ${CSHARP_ROOT}/Directory.Build.props
+ @ONLY)
diff --git a/csharp/Directory.Build.props.in b/csharp/Directory.Build.props.in
new file mode 100644
index 0000000000..6ba441f9f0
--- /dev/null
+++ b/csharp/Directory.Build.props.in
@@ -0,0 +1,8 @@
+
+
+
+
+ @CMAKE_BINARY_DIR@/..
+
+
diff --git a/csharp/sample/Microsoft.ML.OnnxRuntime.InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.csproj b/csharp/sample/Microsoft.ML.OnnxRuntime.InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.csproj
index d304094666..99cdbfa4ec 100644
--- a/csharp/sample/Microsoft.ML.OnnxRuntime.InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.csproj
+++ b/csharp/sample/Microsoft.ML.OnnxRuntime.InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.csproj
@@ -4,8 +4,8 @@
Exe
netcoreapp2.0
..\..
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(buildDirectory)\$(Configuration)\$(Configuration)
+ $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
index 1a5e101767..c140478463 100644
--- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
+++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj
@@ -18,8 +18,8 @@
https://go.microsoft.com/fwlink/?linkid=2049168
..\..
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(buildDirectory)\$(Configuration)\$(Configuration)
+ $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
true
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj
index 6eb14ad8c7..62465677fd 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj
@@ -6,10 +6,10 @@
$(MSBuildThisFileDirectory)..\..
AnyCPU
bin\$(Configuration)\
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(buildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)
+ $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)
$(OnnxRuntimeCsharpRoot)\..\cmake\external\onnx\onnx
- $(buildDirectory)\$(Configuration)\$(Configuration)
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
@@ -29,8 +29,8 @@
Always
false
-
-
+
+
Always
false
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/Microsoft.ML.OnnxRuntime.Tests.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/Microsoft.ML.OnnxRuntime.Tests.csproj
index 252d3ba783..b4fb8de55d 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/Microsoft.ML.OnnxRuntime.Tests.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/Microsoft.ML.OnnxRuntime.Tests.csproj
@@ -6,10 +6,10 @@
..\..
AnyCPU
bin\$(Configuration)\
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(buildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)
+ $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)
$(OnnxRuntimeCsharpRoot)\..\cmake\external\onnx\onnx
- $(buildDirectory)\$(Configuration)\$(Configuration)
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
@@ -37,8 +37,8 @@
Always
false
-
-
+
+
PreserveNewest
false
diff --git a/csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Microsoft.ML.OnnxRuntime.PerfTool.csproj b/csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Microsoft.ML.OnnxRuntime.PerfTool.csproj
index 32c0a205f5..195a5b0303 100644
--- a/csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Microsoft.ML.OnnxRuntime.PerfTool.csproj
+++ b/csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Microsoft.ML.OnnxRuntime.PerfTool.csproj
@@ -4,8 +4,8 @@
Exe
netcoreapp2.0
..\..
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(buildDirectory)\$(Configuration)\$(Configuration)
+ $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
false