Repository.mk                            |    4 +
 bin/distro-install-sdk                   |    1 
 net_ure/CustomTarget_net_nuget_pkg.mk    |   51 +++++++++++++++++++
 net_ure/DotnetLibrary_net_bridge.mk      |   27 ++++++++++
 net_ure/Library_net_bootstrap.mk         |   25 +++++++++
 net_ure/Module_net_ure.mk                |    6 ++
 net_ure/Package_net_bridge.mk            |   18 ++++++
 net_ure/Package_net_nuget_config.mk      |   13 ++++
 net_ure/Package_net_nuget_pkg.mk         |   13 ++++
 net_ure/README.md                        |    8 ++
 net_ure/source/bootstrap/bootstrap.cxx   |   49 ++++++++++++++++++
 net_ure/source/bridge/NativeBootstrap.cs |   32 +++++++++++
 net_ure/source/nuget.config              |    6 ++
 odk/build-examples_common.mk             |    1 
 odk/config/cfgWin.js                     |   83 +++++++++++++++++++++++++++++++
 odk/config/configure.pl                  |   75 ++++++++++++++++++++++++++++
 odk/config/setsdkenv_unix.sh.in          |   12 ++++
 odk/settings/std.mk                      |    1 
 18 files changed, 423 insertions(+), 2 deletions(-)

New commits:
commit 074714fab8db751e2aa0138391a270124733977d
Author:     RMZeroFour <[email protected]>
AuthorDate: Tue Sep 3 00:58:46 2024 +0530
Commit:     Hossein <[email protected]>
CommitDate: Wed Sep 18 08:08:31 2024 +0200

    .NET Bindings: Create nuget package for LO SDK
    
    This patch includes:
    1. CustomTarget to build and place the LibreOffice.Bindings NuGet
       package in <sdk>/dotnet/
    2. net_bridge (.NET library) to declare bootstrap() on the C# side,
       and net_bootstrap (C++ library) to wrap bootstrap() on the native side
    3. Changes to LO SDK scripts to find .NET SDK and DOTNET_ROOT on the
       users machine
    
    Change-Id: Ia29ae56a2ad0f808f1563ef6167a3bd7c476642e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170172
    Tested-by: Jenkins
    Reviewed-by: Hossein <[email protected]>

diff --git a/Repository.mk b/Repository.mk
index cdf2f3b06d39..af89d1d50dce 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -603,6 +603,7 @@ $(eval $(call 
gb_Helper_register_libraries_for_install,PLAINLIBS_URE,ure, \
                $(if $(filter MSC,$(COM)),$(if $(filter-out 
AARCH64_TRUE,$(CPUNAME)_$(CROSS_COMPILING)),cli_uno)) \
        ) \
        i18nlangtag \
+       $(if $(ENABLE_DOTNET),net_bootstrap) \
        $(if $(ENABLE_JAVA), \
                java_uno \
                jpipe \
@@ -897,6 +898,9 @@ $(eval $(call gb_Helper_register_packages_for_install,ure,\
                net_basetypes \
                net_uretypes \
                net_oootypes \
+               net_bridge \
+               net_nuget_pkg \
+               net_nuget_config \
        ) \
        $(if $(ENABLE_JAVA),\
                jvmfwk_jvmfwk3_ini \
diff --git a/bin/distro-install-sdk b/bin/distro-install-sdk
index e8cf28d618d4..aad5c4c8c672 100755
--- a/bin/distro-install-sdk
+++ b/bin/distro-install-sdk
@@ -73,6 +73,7 @@ if test -d $DESTDIR$INSTALLDIR/sdk ; then
         -e "s,@OO_SDK_CPP_HOME@,$(dirname $(command -v cpp))," \
         -e "s,@OO_SDK_SED_HOME@,$(dirname $(command -v sed))," \
         -e "s,@OO_SDK_CAT_HOME@,$(dirname $(command -v cat))," \
+        -e "s,@OO_SDK_DOTNET_ROOT@,$DOTNET_ROOT," \
         -e "s,@OO_SDK_JAVA_HOME@,$JAVA_HOME," \
         -e "s,@OO_SDK_OUTPUT_DIR@,\$HOME," \
         -e "s,@SDK_AUTO_DEPLOYMENT@,NO," \
diff --git a/net_ure/CustomTarget_net_nuget_pkg.mk 
b/net_ure/CustomTarget_net_nuget_pkg.mk
new file mode 100644
index 000000000000..2c92dd4a5213
--- /dev/null
+++ b/net_ure/CustomTarget_net_nuget_pkg.mk
@@ -0,0 +1,51 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call gb_CustomTarget_CustomTarget,net_ure/net_uretypes))
+
+net_nuget_pkg_DIR := $(gb_CustomTarget_workdir)/net_ure/net_nuget_pkg
+net_nuget_pkg_ID := LibreOffice.Bindings
+net_nuget_pkg_VERSION := 0.1.0
+net_nuget_pkg_PROJECT := $(net_nuget_pkg_DIR)/nuget_pkg.csproj
+net_nuget_pkg_FILE := 
$(net_nuget_pkg_DIR)/$(net_nuget_pkg_ID).$(net_nuget_pkg_VERSION).nupkg
+
+$(call gb_CustomTarget_get_target,net_ure/net_nuget_pkg) : 
$(net_nuget_pkg_FILE)
+
+$(net_nuget_pkg_PROJECT) : \
+               $(call gb_DotnetLibrary_get_target,net_bridge) \
+               $(call gb_DotnetLibrary_get_target,net_oootypes) \
+               | $(net_nuget_pkg_DIR)/.dir
+       $(file  >$@,<Project Sdk="Microsoft.NET.Sdk">)
+       $(file >>$@,<PropertyGroup>)
+       $(file >>$@,<TargetFramework>netstandard2.0</TargetFramework>)
+       $(file >>$@,<PackageId>$(net_nuget_pkg_ID)</PackageId>)
+       $(file >>$@,<Version>$(net_nuget_pkg_VERSION)</Version>)
+       $(file >>$@,<Company>LibreOffice</Company>)
+       $(file >>$@,<Description>Libraries for the new .NET language bindings 
for UNO.</Description>)
+       $(file >>$@,<IncludeBuildOutput>false</IncludeBuildOutput>)
+       $(file >>$@,</PropertyGroup>)
+       $(file >>$@,<ItemGroup>)
+       $(file >>$@,<Content Include="$(call 
gb_DotnetLibrary_get_target,net_basetypes)" Pack="true" 
PackagePath="lib/$$(TargetFramework)"/>)
+       $(file >>$@,<Content Include="$(call 
gb_DotnetLibrary_get_target,net_uretypes)" Pack="true" 
PackagePath="lib/$$(TargetFramework)"/>)
+       $(file >>$@,<Content Include="$(call 
gb_DotnetLibrary_get_target,net_oootypes)" Pack="true" 
PackagePath="lib/$$(TargetFramework)"/>)
+       $(file >>$@,<Content Include="$(call 
gb_DotnetLibrary_get_target,net_bridge)" Pack="true" 
PackagePath="lib/$$(TargetFramework)"/>)
+       $(file >>$@,</ItemGroup>)
+       $(file >>$@,</Project>)
+
+$(net_nuget_pkg_FILE) : $(net_nuget_pkg_PROJECT)
+       $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),NET,4)
+       $(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),NET)
+
+       $(call gb_Helper_abbreviate_dirs,\
+               $(call gb_Helper_print_on_error,\
+                       "$(DOTNET)" pack $< -o $(dir $@),\
+                       $(net_nuget_pkg_DIR)/log))
+
+       $(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),NET)
+
+# vim:set shiftwidth=4 tabstop=4 noexpandtab:
diff --git a/net_ure/DotnetLibrary_net_bridge.mk 
b/net_ure/DotnetLibrary_net_bridge.mk
new file mode 100644
index 000000000000..30b320b05b3f
--- /dev/null
+++ b/net_ure/DotnetLibrary_net_bridge.mk
@@ -0,0 +1,27 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call 
gb_DotnetLibrary_DotnetLibrary,net_bridge,$(gb_DotnetLibrary_CS)))
+
+$(eval $(call gb_DotnetLibrary_add_sources,net_bridge,\
+       net_ure/source/bridge/NativeBootstrap \
+))
+
+$(eval $(call gb_DotnetLibrary_add_properties,net_bridge,\
+       
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> \
+))
+
+$(eval $(call gb_DotnetLibrary_link_library,net_bridge,net_uretypes))
+
+$(eval $(call gb_DotnetLibrary_add_properties,net_bridge,\
+       <Version>0.1.0</Version> \
+       <Company>LibreOffice</Company> \
+       <Description>Interprocess bridge for the .NET language UNO 
binding.</Description> \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/net_ure/Library_net_bootstrap.mk b/net_ure/Library_net_bootstrap.mk
new file mode 100644
index 000000000000..9382525f4f00
--- /dev/null
+++ b/net_ure/Library_net_bootstrap.mk
@@ -0,0 +1,25 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,net_bootstrap))
+
+$(eval $(call gb_Library_use_udk_api,net_bootstrap))
+
+$(eval $(call gb_Library_use_libraries,net_bootstrap,\
+       cppu \
+       cppuhelper \
+       sal \
+       salhelper \
+))
+
+$(eval $(call gb_Library_add_exception_objects,net_bootstrap,\
+       net_ure/source/bootstrap/bootstrap \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/net_ure/Module_net_ure.mk b/net_ure/Module_net_ure.mk
index e5bf692114f4..0ae4cd0361c8 100644
--- a/net_ure/Module_net_ure.mk
+++ b/net_ure/Module_net_ure.mk
@@ -10,14 +10,20 @@ $(eval $(call gb_Module_Module,net_ure))
 
 ifeq ($(ENABLE_DOTNET)_$(filter ODK,$(BUILD_TYPE)),TRUE_ODK)
 $(eval $(call gb_Module_add_targets,net_ure,\
+       Library_net_bootstrap \
        CustomTarget_net_uretypes \
        CustomTarget_net_oootypes \
        DotnetLibrary_net_basetypes \
        DotnetLibrary_net_uretypes \
        DotnetLibrary_net_oootypes \
+       DotnetLibrary_net_bridge \
+       CustomTarget_net_nuget_pkg \
        Package_net_basetypes \
        Package_net_uretypes \
        Package_net_oootypes \
+       Package_net_bridge \
+       Package_net_nuget_pkg \
+       Package_net_nuget_config \
 ))
 
 $(eval $(call gb_Module_add_subsequentcheck_targets,net_ure,\
diff --git a/net_ure/Package_net_bridge.mk b/net_ure/Package_net_bridge.mk
new file mode 100644
index 000000000000..64f2c7396e87
--- /dev/null
+++ b/net_ure/Package_net_bridge.mk
@@ -0,0 +1,18 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call 
gb_Package_Package,net_bridge,$(gb_DotnetLibrary_workdir)/net_bridge))
+
+$(gb_DotnetLibrary_workdir)/net_bridge/net_bridge.runtimeconfig.json : $(call 
gb_DotnetLibrary_get_target,net_bridge)
+
+$(eval $(call gb_Package_add_files,net_bridge,$(LIBO_SHARE_DOTNET_FOLDER),\
+       net_bridge.dll \
+       net_bridge.runtimeconfig.json \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/net_ure/Package_net_nuget_config.mk 
b/net_ure/Package_net_nuget_config.mk
new file mode 100644
index 000000000000..d796b9ea9d20
--- /dev/null
+++ b/net_ure/Package_net_nuget_config.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call gb_Package_Package,net_nuget_config,$(SRCDIR)/net_ure/source))
+
+$(eval $(call 
gb_Package_add_files,net_nuget_config,$(SDKDIRNAME)/dotnet,nuget.config))
+
+# vim: set noet sw=4 ts=4:
diff --git a/net_ure/Package_net_nuget_pkg.mk b/net_ure/Package_net_nuget_pkg.mk
new file mode 100644
index 000000000000..8e478810d2fd
--- /dev/null
+++ b/net_ure/Package_net_nuget_pkg.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call 
gb_Package_Package,net_nuget_pkg,$(gb_CustomTarget_workdir)/net_ure/net_nuget_pkg))
+
+$(eval $(call 
gb_Package_add_files,net_nuget_pkg,$(SDKDIRNAME)/dotnet,LibreOffice.Bindings.0.1.0.nupkg))
+
+# vim: set noet sw=4 ts=4:
diff --git a/net_ure/README.md b/net_ure/README.md
index 042981eb9113..a890e1496254 100644
--- a/net_ure/README.md
+++ b/net_ure/README.md
@@ -1,5 +1,9 @@
 # .NET UNO Runtime Environment
 
-Support assemblies and tools for the newer cross-platform .NET UNO binding.
+.NET assemblies for the newer cross-platform .NET UNO binding.
 
-Currently only contains code for the `net_basetypes` assembly in the 
source/basetypes subdirectory, as well as Makefiles to build the `net_uretypes` 
(for `udkapi`) and `net_oootypes` (for `offapi`) assemblies, using `netmaker` 
from the codemaker/ module
\ No newline at end of file
+Contains code for the `net_basetypes` assembly, `net_bridge` assembly, and 
`net_bootstrap` native library, along with unit tests.
+Includes scripts to build the `net_uretypes` and `net_oootypes` assemblies 
from IDL, using `netmaker` from the codemaker/ module.
+Also includes scripts to build the `LibreOffice.Bindings` nuget package for 
the SDK.
+
+The assemblies compile and can be consumed against .NET Standard 2.0, although 
the build requirement is set to .NET SDK 8.0 or higher for tests and examples, 
and to ensure cross platform uniformity.
\ No newline at end of file
diff --git a/net_ure/source/bootstrap/bootstrap.cxx 
b/net_ure/source/bootstrap/bootstrap.cxx
new file mode 100644
index 000000000000..97bff2ab6506
--- /dev/null
+++ b/net_ure/source/bootstrap/bootstrap.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <string_view>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <o3tl/string_view.hxx>
+#include <rtl/bootstrap.hxx>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void* bootstrap(const sal_Unicode* sParams)
+{
+    try
+    {
+        if (sParams)
+        {
+            OUString paramsStr(sParams);
+            for (size_t i = 0; i != std::u16string_view::npos;)
+            {
+                std::u16string_view name(o3tl::getToken(paramsStr, u'=', i));
+                OUString key(name.substr(0, name.find_first_of('|')));
+                OUString val(name.substr(key.getLength() + 1));
+                ::rtl::Bootstrap::set(key, val);
+            }
+        }
+
+        Reference<XComponentContext> xContext(::cppu::bootstrap());
+        return xContext.get();
+    }
+    catch (...)
+    {
+        return nullptr;
+    }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/net_ure/source/bridge/NativeBootstrap.cs 
b/net_ure/source/bridge/NativeBootstrap.cs
new file mode 100644
index 000000000000..d7a3cee9c8cf
--- /dev/null
+++ b/net_ure/source/bridge/NativeBootstrap.cs
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Linq;
+
+namespace com.sun.star.uno
+{
+    public static class NativeBootstrap
+    {
+        public static XComponentContext bootstrap()
+        {
+            Interop.bootstrap(null);
+            return null;
+        }
+
+        private static class Interop
+        {
+            private const string BOOTSTRAP_LIBRARY = "net_bootstrap";
+
+            [DllImport(BOOTSTRAP_LIBRARY, CallingConvention = 
CallingConvention.Cdecl)]
+            public static extern IntPtr 
bootstrap([MarshalAs(UnmanagedType.LPWStr)] string sParams);
+        }
+    }
+}
diff --git a/net_ure/source/nuget.config b/net_ure/source/nuget.config
new file mode 100644
index 000000000000..24b87a5adcf7
--- /dev/null
+++ b/net_ure/source/nuget.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <packageSources>
+    <add key="LibreOfficeSDK" value="%OO_SDK_HOME%" />
+  </packageSources>
+</configuration>
\ No newline at end of file
diff --git a/odk/build-examples_common.mk b/odk/build-examples_common.mk
index 546ef5e4bd46..e71e60714a0f 100644
--- a/odk/build-examples_common.mk
+++ b/odk/build-examples_common.mk
@@ -67,6 +67,7 @@ $(gb_CustomTarget_workdir)/$(1)/setsdkenv: \
        -e 's!@OFFICE_HOME@!$(INSTROOTBASE)!' -e 's!@OO_SDK_MAKE_HOME@!!' \
        -e 's!@OO_SDK_ZIP_HOME@!!' -e 's!@OO_SDK_CAT_HOME@!!' \
        -e 's!@OO_SDK_SED_HOME@!!' -e 's!@OO_SDK_CPP_HOME@!!' \
+       -e 's!@OO_SDK_DOTNET_ROOT@!"$(DOTNET_ROOT)"!' \
        -e 's!@OO_SDK_JAVA_HOME@!$(JAVA_HOME)!' \
        -e 's!@OO_SDK_OUTPUT_DIR@!$(gb_CustomTarget_workdir)/$(1)/out!' \
        -e 's!@SDK_AUTO_DEPLOYMENT@!YES!' $$< > $$@
diff --git a/odk/config/cfgWin.js b/odk/config/cfgWin.js
index 6cfdce68f36a..9076efe426ea 100644
--- a/odk/config/cfgWin.js
+++ b/odk/config/cfgWin.js
@@ -62,6 +62,7 @@ var oo_sdk_manifest_used="";
 var oo_sdk_windowssdk="";
 var oo_sdk_cpp_home=getCppHome();
 var oo_sdk_cli_home=getCliHome();
+var oo_sdk_dotnet_root=getDotnetRoot();
 var oo_sdk_java_home=getJavaHome();
 var oo_sdk_out=getOutputDir();
 var sdk_auto_deployment=getAutoDeployment();
@@ -634,6 +635,78 @@ function getCliHome()
     }
 }
 
+function getDotnetRoot()
+{
+    var sSuggestedHome = WshSysEnv("OO_SDK_DOTNET_ROOT");
+    if (sSuggestedHome.length == 0)
+    {
+        try {
+            var sWhereResult = WshShell.Exec("where.exe 
dotnet.exe").StdOut.ReadLine();
+            if (sWhereResult.length > 0)
+            {
+                sSuggestedHome = sWhereResult;
+                if (!aFileSystemObject.FolderExists(sSuggestedHome))
+                    sSuggestedHome = "";
+            }
+        } catch (exc) {}
+    }
+
+    var bSkip = false;
+    while(true)
+    {
+        stdout.Write("
 Enter .NET SDK (8 or higher) installation directory (optional) [" + 
sSuggestedHome + "]:");
+        var sHome = stdin.ReadLine();
+        if (sHome.length == 0)
+        {
+            //No user input, check OO_SDK_DOTNET_ROOT or suggested value
+                       if ( sSuggestedHome.length == 0 ) {
+                           bSkip = true;
+                       } else {
+                           if ( 
!aFileSystemObject.FolderExists(sSuggestedHome) )
+                               {
+                                       stdout.WriteLine("
 Error: Could not find directory \"" +
+                                                                        
sSuggestedHome + "\".");
+                                       sSuggestedHome = "";
+                                       bSkip=true;
+                               }
+                       }
+
+                       sHome = sSuggestedHome;
+        } else
+        {
+            //validate the user input
+            if ( ! aFileSystemObject.FolderExists(sHome))
+            {
+                stdout.WriteLine("
 Error: The directory \"" + sHome +
+                                 "\" does not exist.");
+                               bSkip = true;
+            }
+        }
+
+               if ( !bSkip) {
+                   //Check if this is an sdk folder by looking for the dotnet 
executable
+                       var dotnetExe = sHome + "\dotnet.exe";
+                       if (! aFileSystemObject.FileExists(dotnetExe))
+                       {
+                               stdout.WriteLine("
 Error: Could not find \"" +
+                                                                dotnetExe + 
"\".");
+                               bSkip = true;
+                       }
+        }
+
+               if ( bSkip ) {
+                  if ( skipChoice("the .NET SDK") ) {
+                          return "";
+                  } else {
+                          bSkip = false;
+                          continue;
+                  }
+               }
+
+        return sHome;
+    }
+}
+
 function getJavaHome()
 {
     var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME");
@@ -879,6 +952,10 @@ function writeBatFile(fdir, file)
         "REM Example:set 
OO_SDK_CLI_HOME=C:\WINXP\Microsoft.NET\Framework\v1.0.3705
" +
         "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home +
         "

" +
+        "REM .NET SDK installation directory.
" +
+        "REM Example: set OO_SDK_DOTNET_ROOT=C:\Program Files\Java\jdk1.6.0_05
" +
+        "set OO_SDK_DOTNET_ROOT=" + oo_sdk_dotnet_root +
+        "

" +
         "REM Java SDK installation directory.
" +
         "REM Example: set OO_SDK_JAVA_HOME=C:\Program Files\Java\jdk1.6.0_05
" +
         "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home +
@@ -948,9 +1025,11 @@ function writeBatFile(fdir, file)
         "set OO_SDK_URE_BIN_DIR=%OFFICE_PROGRAM_PATH%
" +
         "set OO_SDK_URE_LIB_DIR=%OFFICE_PROGRAM_PATH%
" +
         "set OO_SDK_URE_JAVA_DIR=%OFFICE_PROGRAM_PATH%\classes
" +
+        "set OO_SDK_URE_DOTNET_DIR=%OFFICE_PROGRAM_PATH%\dotnet
" +
         "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%
" +
         "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_PROGRAM_PATH%
" +
         "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_PROGRAM_PATH%\classes
" +
+        "set OO_SDK_OFFICE_DOTNET_DIR=%OFFICE_PROGRAM_PATH%\dotnet
" +
         "
" +
         "REM Set classpath
" +
         "set 
CLASSPATH=%OO_SDK_URE_JAVA_DIR%\libreoffice.jar;%OO_SDK_URE_JAVA_DIR%\unoloader.jar
" +
@@ -983,6 +1062,9 @@ function writeBatFile(fdir, file)
         "REM Add directory of the C# and VB.NET compilers to the path, if 
necessary.
" +
         "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%
" +
         "
" +
+        "REM Add directory of the dotnet command-line tool to the path, if 
necessary.
" +
+        "if defined OO_SDK_DOTNET_ROOT set PATH=%OO_SDK_DOTNET_ROOT%;%PATH%
" +
+        "
" +
         "REM Add directory of the Java tools to the path, if necessary.
" +
         "if defined OO_SDK_JAVA_HOME set 
PATH=%OO_SDK_JAVA_HOME%\bin;%OO_SDK_JAVA_HOME%\jre\bin;%PATH%
" +
         "
" +
@@ -1005,6 +1087,7 @@ function writeBatFile(fdir, file)
         "echo  * sed = %OO_SDK_SED_HOME%
" +
         "echo  * C++ Compiler = %OO_SDK_CPP_HOME%
" +
         "echo  * C# and VB.NET compilers = %OO_SDK_CLI_HOME%
" +
+        "echo  * Dotnet = %OO_SDK_DOTNET_ROOT%
" +
         "echo  * Java = %OO_SDK_JAVA_HOME%
" +
         "echo  * Special Output directory = %OO_SDK_OUT%
" +
         "echo  * Auto deployment = %SDK_AUTO_DEPLOYMENT%
" +
diff --git a/odk/config/configure.pl b/odk/config/configure.pl
index 756db5a3c76b..e3e1e1adea43 100755
--- a/odk/config/configure.pl
+++ b/odk/config/configure.pl
@@ -73,6 +73,10 @@ $main::cppName = "gcc";
 $main::cppVersion = "4.0.1";
 $main::OO_SDK_CPP_HOME_SUGGESTION = searchprog($main::cppName);
 
+$main::OO_SDK_DOTNET_ROOT = "";
+$main::OO_SDK_DOTNET_ROOT_SUGGESTION = dotnetToRoot(searchprog("dotnet") . 
"/dotnet");
+$main::dotnetSdkVersion = "8";
+
 $main::OO_SDK_JAVA_HOME = "";
 $main::OO_SDK_JAVA_HOME_SUGGESTION = searchprog("javac");
 $main::javaVersion = "1.6";
@@ -378,6 +382,52 @@ while ( (!$main::correctVersion) &&
     }
 }
 
+# prepare .NET SDK path
+$main::correctVersion = 0;
+while ( (!$main::correctVersion) &&
+        ((! -d "$main::OO_SDK_DOTNET_ROOT" ) ||
+         ((-d "$main::OO_SDK_DOTNET_ROOT") && (! -e 
"$main::OO_SDK_DOTNET_ROOT/dotnet"))) )
+{
+    print " Enter .NET SDK (8 or higher) installation directory (optional) 
[$main::OO_SDK_DOTNET_ROOT_SUGGESTION]: ";
+    $main::OO_SDK_DOTNET_ROOT = readStdIn();
+    chop($main::OO_SDK_DOTNET_ROOT);
+    if ( $main::OO_SDK_DOTNET_ROOT eq "" )
+    {
+        $main::OO_SDK_DOTNET_ROOT = $main::OO_SDK_DOTNET_ROOT_SUGGESTION;
+    }
+    if ( ! $main::OO_SDK_DOTNET_ROOT eq "" )
+    {
+        if ( (! -d "$main::OO_SDK_DOTNET_ROOT") ||
+             ((-d "$main::OO_SDK_DOTNET_ROOT") && (! -e 
"$main::OO_SDK_DOTNET_ROOT/dotnet")) )
+        {
+            print " Error: Could not find directory 
'$main::OO_SDK_DOTNET_ROOT' or '$main::OO_SDK_DOTNET_ROOT/dotnet'.
";
+            if ( skipChoice(".NET SDK") == 1 )
+            {
+                $main::correctVersion = 1;
+            }
+            $main::OO_SDK_DOTNET_ROOT = "";
+        } else
+        {
+            #check version
+            my $testVersion = `"$main::OO_SDK_DOTNET_ROOT/dotnet" --version | 
awk -F. '{ print $1 }'`;
+
+            $main::correctVersion = testVersion($main::dotnetSdkVersion, 
$testVersion, "$main::OO_SDK_DOTNET_ROOT/dotnet", 1);
+            if ( !$main::correctVersion )
+            {
+                print " The 'dotnet' command found at 
'$main::OO_SDK_DOTNET_ROOT' has a wrong version
";
+                if ( skipChoice(".NET SDK") == 1 )
+                {
+                    $main::correctVersion = 1;
+                }
+                $main::OO_SDK_DOTNET_ROOT = "";
+            }
+        }
+    }else
+    {
+        # the .NET SDK is optional
+        $main::correctVersion = 1;
+    }
+}
 
 # prepare Java path
 $main::correctVersion = 0;
@@ -694,7 +744,31 @@ sub searchoffice
     return $officepath;
 }
 
+sub dotnetToRoot
+{
+    my $dotnetExe = shift;
 
+    if (! -e "$dotnetExe")
+    {
+        return "";
+    }
+
+    my $dotnetSdkVer = `"$dotnetExe" --version`;
+    chomp($dotnetSdkVer);
+
+    my $dotnetSdkDir = `"$dotnetExe" --list-sdks | grep $dotnetSdkVer | awk 
-F'[][]' '{print \$2}'`;
+    chomp($dotnetSdkDir);
+
+    my $dotnetRootDir = `dirname "$dotnetSdkDir"`;
+    chomp($dotnetRootDir);
+
+    if (! -d "$dotnetRootDir")
+    {
+        return "";
+    }
+
+    return $dotnetRootDir;
+}
 
 sub testVersion
 {
@@ -765,6 +839,7 @@ sub prepareScriptFile()
         $_ =~ s#\@OO_SDK_CAT_HOME\@#$main::OO_SDK_CAT_HOME#go;
         $_ =~ s#\@OO_SDK_SED_HOME\@#$main::OO_SDK_SED_HOME#go;
         $_ =~ s#\@OO_SDK_CPP_HOME\@#$main::OO_SDK_CPP_HOME#go;
+        $_ =~ s#\@OO_SDK_DOTNET_ROOT\@#"$main::OO_SDK_DOTNET_ROOT"#go;
         $_ =~ s#\@OO_SDK_JAVA_HOME\@#$main::OO_SDK_JAVA_HOME#go;
         $_ =~ s#\@SDK_AUTO_DEPLOYMENT\@#$main::SDK_AUTO_DEPLOYMENT#go;
         $_ =~ s#\@OO_SDK_OUTPUT_DIR\@#$main::OO_SDK_OUTPUT_DIR#go;
diff --git a/odk/config/setsdkenv_unix.sh.in b/odk/config/setsdkenv_unix.sh.in
index 7feda4159e01..28cf2a6c3c3e 100644
--- a/odk/config/setsdkenv_unix.sh.in
+++ b/odk/config/setsdkenv_unix.sh.in
@@ -54,6 +54,10 @@ OO_SDK_SED_HOME=@OO_SDK_SED_HOME@
 # Example: OO_SDK_CPP_HOME=/usr/bin
 OO_SDK_CPP_HOME=@OO_SDK_CPP_HOME@
 
+# Directory of the .NET SDK.
+# Example: OO_SDK_DOTNET_ROOT=/usr/lib/dotnet
+OO_SDK_DOTNET_ROOT=@OO_SDK_DOTNET_ROOT@
+
 # Directory of the Java SDK.
 # Example: OO_SDK_JAVA_HOME=/usr/jdk/jdk1.6.0_10
 OO_SDK_JAVA_HOME=@OO_SDK_JAVA_HOME@
@@ -239,6 +243,13 @@ then
     export OO_SDK_CPP_HOME
 fi
 
+# Add directory of the dotnet command-line tool to the path, if necessary.
+if [ -n "${OO_SDK_DOTNET_ROOT}" ]
+then
+    PATH=${OO_SDK_DOTNET_ROOT}:${PATH}
+    export OO_SDK_DOTNET_ROOT
+fi
+
 # Add directory of the Java tools to the path, if necessary.
 if [ -n "${OO_SDK_JAVA_HOME}" ]
 then
@@ -293,6 +304,7 @@ echo " * Zip = $OO_SDK_ZIP_HOME"
 echo " * cat = $OO_SDK_CAT_HOME"
 echo " * sed = $OO_SDK_SED_HOME"
 echo " * C++ Compiler = $OO_SDK_CPP_HOME"
+echo " * Dotnet = $OO_SDK_DOTNET_ROOT"
 echo " * Java = $OO_SDK_JAVA_HOME"
 echo " * SDK Output directory = $OO_SDK_OUT"
 echo " * Auto deployment = $SDK_AUTO_DEPLOYMENT"
diff --git a/odk/settings/std.mk b/odk/settings/std.mk
index 2a0763222e6d..9b4e482ac80f 100644
--- a/odk/settings/std.mk
+++ b/odk/settings/std.mk
@@ -70,6 +70,7 @@ endif
 endif
 
 DEPLOYTOOL="$(OFFICE_PROGRAM_PATH)$(PS)unopkg" add -f
+SDK_DOTNET="$(OO_SDK_DOTNET_ROOT)/dotnet"
 SDK_JAVA="$(OO_SDK_JAVA_HOME)/bin/java" $(JAVA_OPTIONS)
 SDK_JAVAC="$(OO_SDK_JAVA_HOME)/bin/javac"
 SDK_JAR="$(OO_SDK_JAVA_HOME)/bin/jar"

Reply via email to