Publishing SQL Core library in nuget (#2173)

* Set up CI with Azure Pipelines

[skip ci]

* Update publishSqlCoreProject.yml for Azure Pipelines

* Update publishSqlCoreProject.yml for Azure Pipelines

* Update publishSqlCoreProject.yml for Azure Pipelines

* Update publishSqlCoreProject.yml for Azure Pipelines

* Update publishSqlCoreProject.yml for Azure Pipelines

* Updating json rpc target framework

* Fixing packages to pack

* fixing pattern

* Fixing project pattern

* adding versioning schema

* fixing versioning scheme

* fixing nuget package name

* adding name

* removing var

* Fixing stuff

* Fixing stuff

* Fixing stuff

* Fixing build name

* removing build name

* fixing name

* fixing stuff

* fix pattern

* Fixing stuff

* Fixing feed

* Fix stuff

* Fixing feed

* fixing proj name

* Fixing stuff

* Fixing netframework version

* Fixing target framework

* Adding target framework to dependency

* Fixing frameworks

* adding net7.0

* adding flag

* Fixing target frameworks and making code compatible with lang version

* fixed flag

* Fixing assembly name

* Adding hosting in nuget package

* Fixing tests

* Moving steps to its main pipeline

* only releasing when release is true

* Fixing build scripts

* Adding version to csproj for packaging

* adding version

* Fix dirs

* Adding version number to right prop group

* Adding necessary dis

* Fixing build number

* fixing datatype

* Using different var

* Removing unused yml

* Adding back nullables to hosting

* Adding back more nullables

* adding back more nullables

* moving some props to dir level

* Fixing tests

* Removing dup properties

* Supporting different target frameworks in hosting

* Removing additional setting in csproj

* signing sql core dll in publish

* Fixing version setting

* Adding to build

* Added signing and packaging flag

* Fixing file pattern
This commit is contained in:
Aasim Khan
2023-08-23 06:15:20 +00:00
committed by GitHub
parent 58923bc75e
commit c7d75fa535
39 changed files with 183 additions and 41 deletions

View File

@@ -12,6 +12,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<DebugType>portable</DebugType>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifiers>$(ToolsServiceTargetRuntimes)</RuntimeIdentifiers>
<!-- False alerts, disabled due to issue: https://github.com/dotnet/roslyn/issues/65850 -->
<NoWarn>$(NoWarn);CS8795</NoWarn>

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@@ -18,6 +18,7 @@
This is a Diagnostic Alert .NET 7 onwards.Changing to LibraryImportAttribute would require additional code changes,
therefore this warning is suppressed.-->
<NoWarn>$(NoWarn);SYSLIB1054</NoWarn>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="**/obj/**/*.cs" />

View File

@@ -24,7 +24,8 @@ namespace Microsoft.SqlTools.Extensibility
"microsofsqltoolscredentials.dll",
"microsoft.sqltools.hosting.dll",
"microsoftsqltoolsservicelayer.dll",
"microsoftkustoservicelayer.dll"
"microsoftkustoservicelayer.dll",
"microsoft.sqltools.sqlcore.dll"
};
private Func<ConventionBuilder, ContainerConfiguration> config;

View File

@@ -121,7 +121,11 @@ namespace Microsoft.SqlTools.Hosting.Protocol
public async Task WaitForExitAsync()
{
this.endpointExitedTask = new TaskCompletionSource<bool>();
#if NETSTANDARD2_0
await this.endpointExitedTask.Task;
#else
await this.endpointExitedTask.Task.WaitAsync(CancellationToken.None);
#endif
}
public async Task Stop()

View File

@@ -11,6 +11,8 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyTitle>SqlTools Hosting Library</AssemblyTitle>
<Description>Provides hosting services for SqlTools applications.</Description>
<TargetFrameworks>netstandard2.0;net7.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="**/obj/**/*.cs" />

View File

@@ -202,7 +202,11 @@ namespace Microsoft.SqlTools.Utility
int uniqueId;
try
{
#if NETSTANDARD2_0
uniqueId = Process.GetCurrentProcess().Id;
#else
uniqueId = Environment.ProcessId;
#endif
}
catch (Exception ex)
{
@@ -256,8 +260,10 @@ namespace Microsoft.SqlTools.Utility
/// Writes a PII message to the log file with the Verbose event level when PII flag is enabled.
/// </summary>
/// <param name="logMessage">The message text to be written.</param>
public static void Pii(string logMessage) {
if (IsPiiEnabled) {
public static void Pii(string logMessage)
{
if (IsPiiEnabled)
{
Write(TraceEventType.Verbose, logMessage);
}
}

View File

@@ -3,6 +3,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#if NETSTANDARD2_0
using System;
#endif
using System.Diagnostics.Tracing;
using Microsoft.SqlTools.Utility;
@@ -41,7 +44,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
{
if (payload != null)
{
#if NETSTANDARD2_0_OR_GREATER
Logger.Verbose($"eventTID:{Environment.CurrentManagedThreadId} {payload.ToString()}");
#else
Logger.Verbose($"eventTID:{eventData.OSThreadId} {payload.ToString()}");
#endif
}
}

View File

@@ -37,6 +37,7 @@
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<!-- Disable CA1852 (Seal internal types) as it depends on SrGen Tool -->
<NoWarn>$(NoWarn);CA1852</NoWarn>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" />

View File

@@ -16,6 +16,7 @@
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
<AssemblyTitle>SqlTools Migration Host Protocol Library</AssemblyTitle>
<Description>Provides message types and client/server APIs for the SqlTools Migration Services JSON protocol.</Description>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

View File

@@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<StartupObject />
<Description>Provides Resource Provider and control plane services for SqlTools applications.</Description>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" />

View File

@@ -12,6 +12,7 @@
<Copyright><EFBFBD> Microsoft Corporation. All rights reserved.</Copyright>
<!-- Disable CA1852 (Seal internal types) as it depends on SrGen Tool -->
<NoWarn>$(NoWarn);CA1852</NoWarn>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" />

View File

@@ -12,6 +12,7 @@
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
<RuntimeIdentifiers>$(ToolsServiceTargetRuntimes)</RuntimeIdentifiers>
<TargetFramework>net7.0</TargetFramework>
<!-- Disable CA1852 (Seal internal types) as it depends on SrGen Tool -->
<NoWarn>$(NoWarn);CA1852</NoWarn>
</PropertyGroup>

View File

@@ -83,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer
"microsofsqltoolscredentials.dll",
"microsoft.sqltools.hosting.dll",
"microsoftsqltoolsservicelayer.dll",
"microsoftsqltoolssqlcore.dll"
"microsoft.sqltools.sqlcore.dll"
});
serviceProvider.RegisterSingleService(sqlToolsContext);
serviceProvider.RegisterSingleService(serviceHost);

View File

@@ -16,6 +16,7 @@
<Description>Provides message types and client/server APIs for the SqlTools Editor Services JSON protocol.</Description>
<!-- False alerts, disabled due to issue: https://github.com/dotnet/roslyn/issues/65850 -->
<NoWarn>$(NoWarn);CS8795</NoWarn>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@@ -12,6 +12,10 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyTitle>SqlTools SqlCore Library</AssemblyTitle>
<Description>Provides core sql functionality for SQL server editors like Object explorer, Query Execution and Scripting</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<AssemblyName>Microsoft.SqlTools.SqlCore</AssemblyName>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="**/obj/**/*.cs" />
@@ -21,7 +25,7 @@
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />
<ProjectReference Include="../Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\*.resx" />

View File

@@ -13,7 +13,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// <summary>
/// Has information for filtering a SMO object by properties
/// </summary>
public interface INodeFilter
public abstract class INodeFilter
{
/// <summary>
/// Returns true if the filter can be apply to the given type and Server type
@@ -21,15 +21,15 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// <param name="type">Type of the querier</param>
/// <param name="validForFlag">Server Type</param>
/// <returns></returns>
bool CanApplyFilter(Type type, ValidForFlag validForFlag);
public abstract bool CanApplyFilter(Type type, ValidForFlag validForFlag);
/// <summary>
/// Creates a string from the filter property and values to be used in the Urn to query the SQL objects
/// Example of the output:[@ IsSystemObject = 0]
/// </summary>
/// <returns></returns>
string ToPropertyFilterString(Type type, ValidForFlag validForFlag);
public abstract string ToPropertyFilterString(Type type, ValidForFlag validForFlag);
/// <summary>
/// Creates a fully paramaterized property filter string for the URN query for SQL objects.
/// Example of the output:[@ IsSystemObject = 0]

View File

@@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// </summary>
/// <param name="type">Type of the querier</param>
/// <param name="validForFlag">Server Type</param>
public bool CanApplyFilter(Type type, ValidForFlag validForFlag) {
public override bool CanApplyFilter(Type type, ValidForFlag validForFlag) {
return this.FilterList.Exists(f => f.CanApplyFilter(type, validForFlag));
}
@@ -33,7 +33,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// Example of the output: ((@TableTemporalType = 1) or (@LedgerTableType = 1))
/// </summary>
/// <returns></returns>
public string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
public override string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
{
StringBuilder filter = new StringBuilder();
foreach (var nodeFilter in FilterList)

View File

@@ -64,7 +64,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// <param name="type">Type of the querier</param>
/// <param name="validForFlag">Server Type</param>
/// <returns></returns>
public bool CanApplyFilter(Type type, ValidForFlag validForFlag)
public override bool CanApplyFilter(Type type, ValidForFlag validForFlag)
{
bool canApplyFilter = false;
canApplyFilter = TypeToReverse == null || TypeToReverse == type;
@@ -78,7 +78,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
/// Example of the output: (@ IsSystemObject = 0)
/// </summary>
/// <returns></returns>
public string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
public override string ToPropertyFilterString(Type type, ValidForFlag validForFlag)
{
// check first if the filter can be applied; if not just return empty string
if (!CanApplyFilter(type, validForFlag))
@@ -186,7 +186,10 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
var escapedString = StringUtils.EscapeStringSQuote(propertyValue.ToString());
if (this.FilterType == FilterType.STARTSWITH || this.FilterType == FilterType.ENDSWITH)
{
escapedString = EscapeLikeURNRegex().Replace(escapedString, "[$0]");
// For filters that use the LIKE operator, we need to escape the following characters: %, _, [, ^
// we do this by wrapping them in square brackets eg: [%], [_], [[], [^]
Regex escapteSqlObjectChars = new Regex(@"%|_|\[|\^");
escapedString = escapteSqlObjectChars.Replace(escapedString, "[$0]");
if (this.FilterType == FilterType.STARTSWITH)
{
@@ -283,11 +286,6 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
return false;
}
}
// For filters that use the LIKE operator, we need to escape the following characters: %, _, [, ^
// we do this by wrapping them in square brackets eg: [%], [_], [[], [^]
[GeneratedRegexAttribute(@"%|_|\[|\^")]
public static partial Regex EscapeLikeURNRegex();
}
public enum FilterType

View File

@@ -323,7 +323,7 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.Nodes
}
}
}
ApplicableNodeChildFactories = new Lazy<Dictionary<string, HashSet<ChildFactory>>>(factories);
ApplicableNodeChildFactories = new Lazy<Dictionary<string, HashSet<ChildFactory>>>(() => factories);
}
public IEnumerable<ChildFactory> GetApplicableChildFactories()

View File

@@ -42,7 +42,9 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
{
NodeTypeDictionary.Add(containedType, new HashSet<Node>());
}
NodeTypeDictionary.GetValueOrDefault(containedType).Add(node);
HashSet<Node> nodeSet;
NodeTypeDictionary.TryGetValue(containedType, out nodeSet);
nodeSet.Add(node);
}
}
var serverNode = TreeRoot.Nodes.FirstOrDefault(node => node.Name == "Server");
@@ -59,7 +61,8 @@ namespace Microsoft.SqlTools.SqlCore.ObjectExplorer.SmoModel
}
var returnSet = new HashSet<string>();
var matchingNodes = NodeTypeDictionary.GetValueOrDefault(typeName);
HashSet<Node> matchingNodes;
NodeTypeDictionary.TryGetValue(typeName, out matchingNodes);
if (matchingNodes == null)
{
return returnSet;