From cfe4fa405d34ef3119b970a6dd6d69b7a05e699d Mon Sep 17 00:00:00 2001 From: Wei Dai Date: Mon, 14 Mar 2022 23:43:35 -0700 Subject: [PATCH] Replaced SEALNet.sln with SEALNet.sln.in for pure-source-tree build experience. Updated .NET SDK version to 6.0.x. --- CHANGES.md | 18 +++++++++++++++- CMakeLists.txt | 6 ++++++ README.md | 26 +++++++++++------------ dotnet/{SEALNet.sln => SEALNet.sln.in} | 10 ++++----- dotnet/examples/SEALNetExamples.csproj.in | 4 ++-- dotnet/nuget/NUGET.md | 2 +- dotnet/tests/SEALNetTest.csproj.in | 10 ++++----- dotnet/tests/Utilities.cs | 4 ++-- pipelines/nix.yml | 4 ++-- pipelines/windows.yml | 19 ++++++----------- 10 files changed, 59 insertions(+), 44 deletions(-) rename dotnet/{SEALNet.sln => SEALNet.sln.in} (89%) diff --git a/CHANGES.md b/CHANGES.md index 35c10de2d..ca85a275d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,26 @@ # List of Changes +## Version 3.7.3 + +### Features + +- All output files including downloaded thirdparty dependencies and Visual Studio project and solution files will be created in the build directory [(PR 427)](https://github.com/microsoft/SEAL/pull/427). +- Updated .Net SDK version to 6.0.x and supported Visual Studio version to 17 2022. + +## Bug Fixes + +- Removed exceptions in `KeyGenerator::CreateGaloisKeys` when inputs do not include steps so that even when `EncryptionParameterQualifiers::using_batching` is false Galois automorphisms are still available. + +## File Changes + +- `dotnet/SEALNet.sln` is removed. +- `dotnet/SEALNet.sln.in` is added. + ## Version 3.7.2 ### Bug Fixes -- Fixed a bug when Intel HEXL is used [(Issue 411)](https://github.com/microsoft/SEAL/issues/411) [(PR414)](https://github.com/microsoft/SEAL/pull/414). +- Fixed a bug when Intel HEXL is used [(Issue 411)](https://github.com/microsoft/SEAL/issues/411) [(PR 414)](https://github.com/microsoft/SEAL/pull/414). - Fixed an abnormal benchmark case due to AVX512 transitions when Intel HEXL is used [(PR 416)](https://github.com/microsoft/SEAL/pull/416). ## Version 3.7.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index b4c428353..5d85e8e6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -730,6 +730,12 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/dotnet/examples/SEALNetExamples.csproj @ONLY) +# Create SEALNet.sln for Visual Studio to build all dotnet projects +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/dotnet/SEALNet.sln.in + ${CMAKE_CURRENT_BINARY_DIR}/dotnet/SEALNet.sln + @ONLY) + # Set the sealc dynamic library file names to be included in creating # the NuGet package. When building a multi-platform NuGet package, the # dynamic library paths need to be specified explicitly in the NuGet diff --git a/README.md b/README.md index ba9f6e892..49947f5d1 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ A global install requires elevated (root or administrator) privileges. | System | Toolchain | |---|---| -| Windows | Visual Studio 2019 with C++ CMake Tools for Windows | +| Windows | Visual Studio 2022 with C++ CMake Tools for Windows | | Linux | Clang++ (>= 5.0) or GNU G++ (>= 6.0), CMake (>= 3.13) | | macOS/iOS | Xcode toolchain (>= 9.3), CMake (>= 3.13) | | Android | Android Studio | @@ -271,32 +271,32 @@ sudo cmake --install build #### Building and Installing on Windows -On Windows the same scripts above work in a developer command prompt for Visual Studio using either the Ninja or "Visual Studio 16 2019" generators. +On Windows the same scripts above work in a developer command prompt for Visual Studio using either the Ninja or "Visual Studio 17 2022" generators. -When using the Ninja generator, please use the appropriate command prompt depending on the platform you want to build for. If you want to build for x64, please use the **x64 Native Tools Command Prompt for Visual Studio 2019** command prompt to configure and build the library. If you want to build for x86, please use the **x86 Native Tools Command Prompt for Visual Studio 2019** command prompt to configure and build the library. To build using Ninja, type +When using the Ninja generator, please use the appropriate command prompt depending on the platform you want to build for. If you want to build for x64, please use the **x64 Native Tools Command Prompt for Visual Studio 2022** command prompt to configure and build the library. If you want to build for x86, please use the **x86 Native Tools Command Prompt for Visual Studio 2022** command prompt to configure and build the library. To build using Ninja, type ```PowerShell cmake -S . -B build -G Ninja cmake --build build ``` -When using the "Visual Studio 16 2019" generator you can use the **Developer Command Prompt for VS 2019** command prompt to configure and build the library. By default the generated platform will be x64. You can specify the desired platform using the architecture flag `-A ` and the desired configuration using `--config `. +When using the "Visual Studio 17 2022" generator you can use the **Developer Command Prompt for VS 2022** command prompt to configure and build the library. By default the generated platform will be x64. You can specify the desired platform using the architecture flag `-A ` and the desired configuration using `--config `. ```PowerShell # Generate and build for x64 in Release mode -cmake -S . -B build -G "Visual Studio 16 2019" -A x64 +cmake -S . -B build -G "Visual Studio 17 2022" -A x64 cmake --build build --config Release ``` ```PowerShell # Generate and build for x86 in Release mode -cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 +cmake -S . -B build -G "Visual Studio 17 2022" -A Win32 cmake --build build --config Release ``` Installing the library in Windows works as well. Instead of using the `sudo` command, however, you need to run `cmake --install build` from a command prompt with Administrator permissions. Files will be installed by default to `C:\Program Files (x86)\SEAL\`. -Visual Studio 2019 provides support for CMake-based projects. You can select the menu option `File / Open / Folder...` and navigate to the folder where the Microsoft SEAL repository is located. After opening the folder, Visual Studio will detect that this is a CMake-based project and will enable the menu command `Project / CMake settings for SEAL`. This will open the CMake settings editor that provides a user interface where you can create different configurations and set different CMake options. +Visual Studio 2022 provides support for CMake-based projects. You can select the menu option `File / Open / Folder...` and navigate to the folder where the Microsoft SEAL repository is located. After opening the folder, Visual Studio will detect that this is a CMake-based project and will enable the menu command `Project / CMake settings for SEAL`. This will open the CMake settings editor that provides a user interface where you can create different configurations and set different CMake options. After the build completes, the output static library `seal-.lib` can be found in `build\lib\` or `build\lib\Release\`. When linking with applications, using CMake as is explained in [Linking with Microsoft SEAL through CMake](#linking-with-microsoft-seal-through-cmake) is highly recommended. @@ -348,7 +348,7 @@ source ./emsdk_env.sh ``` **On Windows, better run from a developer command prompt for Visual Studio; and replace `./emsdk` and `source ./emsdk_env.sh` with `emsdk` and `emsdk_env.bat`, respectively.** In other environments, `cmake` must be added to the path, and either "Ninja" or "MinGW Makefiles" should be specified as generator in the following configuration step. -`emcmake` does not work with Visual Studio 16 2019 generator. +`emcmake` does not work with Visual Studio 17 2022 generator. Within the same shell, navigate to the root directory of Microsoft SEAL, run the following commands to build for WebAssembly: @@ -483,21 +483,21 @@ The SEAL_C library is meant to be used only by the .NET library, not by end-user #### Windows, Linux, and macOS -For compiling .NET code you will need to install a [.NET Core SDK (>= 3.1)](https://dotnet.microsoft.com/download). +For compiling .NET code you will need to install a [.NET SDK (>= 6.0)](https://dotnet.microsoft.com/download). Building the SEAL_C library with CMake will generate project files for the .NET wrapper library, examples, and unit tests. The SEAL_C library must be discoverable when running a .NET application, e.g., be present in the same directory as your executable, which is taken care of by the .NET examples and tests project files. Run the following scripts to build each project: ```PowerShell -dotnet build dotnet/src --configuration # Build .NET wrapper library -dotnet test dotnet/tests # Build and run .NET unit tests -dotnet run -p dotnet/examples # Build and run .NET examples +dotnet build build/dotnet/src --configuration # Build .NET wrapper library +dotnet test build/dotnet/tests # Build and run .NET unit tests +dotnet run -p build/dotnet/examples # Build and run .NET examples ``` You can use `--configuration ` to run `Debug` or `Release` examples and unit tests. You can use `--verbosity detailed` to print the list of unit tests that are being run. -On Windows, you can also use the Microsoft Visual Studio 2019 solution file `dotnet/SEALNet.sln` to build all three projects. +On Windows, you can also use the Microsoft Visual Studio 2022 solution file, for example, `out/build/x64-Debug/dotnet/SEALNet.sln` to build all three projects. #### Android and iOS diff --git a/dotnet/SEALNet.sln b/dotnet/SEALNet.sln.in similarity index 89% rename from dotnet/SEALNet.sln rename to dotnet/SEALNet.sln.in index d8c1a336d..daf6afbf6 100644 --- a/dotnet/SEALNet.sln +++ b/dotnet/SEALNet.sln.in @@ -1,13 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30011.22 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNet", "src\SEALNet.csproj", "{1FA5DA9A-A2F0-4CC5-9072-5CBA2D1E3D2E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNet", "@CMAKE_CURRENT_BINARY_DIR@\dotnet\src\SEALNet.csproj", "{1FA5DA9A-A2F0-4CC5-9072-5CBA2D1E3D2E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNetExamples", "examples\SEALNetExamples.csproj", "{4D86EEEA-D0CA-46F5-9199-C70A5C637739}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNetExamples", "@CMAKE_CURRENT_BINARY_DIR@\dotnet\examples\SEALNetExamples.csproj", "{4D86EEEA-D0CA-46F5-9199-C70A5C637739}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNetTest", "tests\SEALNetTest.csproj", "{BA3D23D1-93AF-40ED-9771-D4346708CD53}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEALNetTest", "@CMAKE_CURRENT_BINARY_DIR@\dotnet\tests\SEALNetTest.csproj", "{BA3D23D1-93AF-40ED-9771-D4346708CD53}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/dotnet/examples/SEALNetExamples.csproj.in b/dotnet/examples/SEALNetExamples.csproj.in index 0573bad13..d03cf480d 100644 --- a/dotnet/examples/SEALNetExamples.csproj.in +++ b/dotnet/examples/SEALNetExamples.csproj.in @@ -2,11 +2,11 @@ Exe - netcoreapp3.1 + net6.0 Microsoft Research Microsoft Corporation .NET wrapper examples for Microsoft SEAL - Microsoft Corporation 2020 + Microsoft Corporation 2022 diff --git a/dotnet/nuget/NUGET.md b/dotnet/nuget/NUGET.md index 8f76237bb..ebbff74f0 100644 --- a/dotnet/nuget/NUGET.md +++ b/dotnet/nuget/NUGET.md @@ -20,7 +20,7 @@ cd ..\.. After the package is created, copy it from `dotnet\nuget\Release` to a known location (e.g., `C:\NuGetPackages`). To add a reference to the NuGet package, you will need to configure Visual Studio so it can find -packages in this known location. In Microsoft Visual Studio 2019, for example, you can: +packages in this known location. In Microsoft Visual Studio 2022, for example, you can: 1. Select the menu uption `Tools / Options...` 2. On the left pane of the Options dialog, navigate to `NuGet Package Manager / Package Sources` 3. On the right pane of the Options dialog, add a new package source that points to the directory diff --git a/dotnet/tests/SEALNetTest.csproj.in b/dotnet/tests/SEALNetTest.csproj.in index 73ed9345b..f1ad345ee 100644 --- a/dotnet/tests/SEALNetTest.csproj.in +++ b/dotnet/tests/SEALNetTest.csproj.in @@ -1,12 +1,12 @@  - netcoreapp3.1 + net6.0 false Microsoft Research Microsoft Corporation .NET wrapper unit tests for Microsoft SEAL - Microsoft Corporation 2020 + Microsoft Corporation 2022 @@ -15,9 +15,9 @@ - - - + + + diff --git a/dotnet/tests/Utilities.cs b/dotnet/tests/Utilities.cs index 18621f703..fa7d5ed4c 100644 --- a/dotnet/tests/Utilities.cs +++ b/dotnet/tests/Utilities.cs @@ -19,7 +19,7 @@ public static class Utilities /// /// Assert that an exception of the given type is thrown. /// - /// This is a workaround for a unit testing issue in VS 2019. + /// This is a workaround for a unit testing issue in VS 2022. /// When running unit tests a couple of them fail because of a FileNotFoundException being thrown instead /// of the expected exception. The FileNotFoundException is thrown in the boundary between a .Net call /// and a native method, so there is not really much we can do to fix it. As a workaround this method @@ -38,7 +38,7 @@ public static void AssertThrows(Func action, [CallerFilePath] string /// /// Assert that an exception of the given type is thrown. /// - /// This is a workaround for a unit testing issue in VS 2019. + /// This is a workaround for a unit testing issue in VS 2022. /// When running unit tests a couple of them fail because of a FileNotFoundException being thrown instead /// of the expected exception. The FileNotFoundException is thrown in the boundary between a .Net call /// and a native method, so there is not really much we can do to fix it. As a workaround this method diff --git a/pipelines/nix.yml b/pipelines/nix.yml index fb4a47f3d..5659e6a3e 100644 --- a/pipelines/nix.yml +++ b/pipelines/nix.yml @@ -16,10 +16,10 @@ steps: displayName: 'Run unit tests' - task: UseDotNet@2 - displayName: 'Get .NET Core 3.1 SDK' + displayName: 'Get .NET Core 6.0 SDK' inputs: packageType: 'sdk' - version: '3.1.x' + version: '6.0.x' - task: DotNetCoreCLI@2 displayName: 'Run dotnet unit tests' diff --git a/pipelines/windows.yml b/pipelines/windows.yml index b4f67ebc2..c491c0c5b 100644 --- a/pipelines/windows.yml +++ b/pipelines/windows.yml @@ -17,18 +17,11 @@ steps: outputFormat: sarif debugMode: false -- ${{ if eq(parameters.configuration, 'Release') }}: - - task: UseDotNet@2 - displayName: 'Get .NET Core 2.1 SDK' - inputs: - packageType: 'sdk' - version: '2.1.x' - - task: UseDotNet@2 - displayName: 'Get .NET Core 3.1 SDK' + displayName: 'Get .NET Core 6.0 SDK' inputs: packageType: 'sdk' - version: '3.1.302' + version: '6.0.x' - ${{ if eq(parameters.configuration, 'Release') }}: - task: PowerShell@2 @@ -116,8 +109,8 @@ steps: timeout: '1800' ram: '16384' addProjectDirToScanningExclusionList: true - buildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/build/seal.sln' - cleanupBuildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/build/seal.sln /t:Clean' + buildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/build/seal.sln' + cleanupBuildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/build/seal.sln /t:Clean' - task: Semmle@0 displayName: 'Semmle SEALNet' @@ -130,8 +123,8 @@ steps: timeout: '1800' ram: '16384' addProjectDirToScanningExclusionList: true - buildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/dotnet/SEALNet.sln' - cleanupBuildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/dotnet/SEALNet.sln /t:Clean' + buildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/dotnet/SEALNet.sln' + cleanupBuildCommands: '"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild $(Build.SourcesDirectory)/dotnet/SEALNet.sln /t:Clean' - task: PublishSymbols@2 displayName: 'Publish symbols path'