diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index 6a269680cb..92f7e504fb 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -130,8 +130,7 @@ $(OrtConstants);__ENABLE_TRAINING_APIS__ diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj index dafebd9ccb..5f3ef40351 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj @@ -19,7 +19,9 @@ + Should be set to true when training is enabled in onnxruntime native binary + Note: This property should be set when building the csharp solution independently. + When building using the build.py script, setting the necessary properties is handled by the script. --> false diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 9155098105..ad1ef28673 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -2000,7 +2000,9 @@ def build_nuget_package( target_name = "/t:CreatePackage" execution_provider = '/p:ExecutionProvider="None"' package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime"' + enable_training_tests = '/p:TrainingEnabledNativeBuild="false"' if enable_training_apis: + enable_training_tests = '/p:TrainingEnabledNativeBuild="true"' if use_cuda: package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Training.Gpu"' else: @@ -2047,7 +2049,16 @@ def build_nuget_package( configuration = '/p:Configuration="' + config + '"' if not use_winml: - cmd_args = ["dotnet", "msbuild", sln, configuration, package_name, is_linux_build, ort_build_dir] + cmd_args = [ + "dotnet", + "msbuild", + sln, + configuration, + package_name, + is_linux_build, + ort_build_dir, + enable_training_tests, + ] run_subprocess(cmd_args, cwd=csharp_build_dir) else: winml_interop_dir = os.path.join(source_dir, "csharp", "src", "Microsoft.AI.MachineLearning.Interop") @@ -2109,7 +2120,7 @@ def run_csharp_tests(source_dir, build_dir, use_cuda, use_openvino, use_tensorrt if use_cuda: macros += "USE_CUDA;" if enable_training_apis: - macros += "__TRAINING_ENABLED_NATIVE_BUILD__;" + macros += "__TRAINING_ENABLED_NATIVE_BUILD__;__ENABLE_TRAINING_APIS__" define_constants = "" if macros != "":