Skip to content

Commit

Permalink
updating to dotnet 8.0 (#170)
Browse files Browse the repository at this point in the history
* updating to dotnet 8.0

* update install script

* better message, set pip install in template testing to skip by default

* revert dev shell
  • Loading branch information
robch authored Feb 8, 2024
1 parent f569ced commit 39691ad
Show file tree
Hide file tree
Showing 28 changed files with 167 additions and 64 deletions.
8 changes: 4 additions & 4 deletions .azure/pipelines/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ stages:
includeNuGetOrg: false
command: custom
custom: tool
version: '7.0.x'
version: '8.0.x'
arguments: install
--ignore-failed-sources
--add-source "$(System.DefaultWorkingDirectory)"
Expand Down Expand Up @@ -274,7 +274,7 @@ stages:
inputs:
includeNuGetOrg: false
command: build
version: '7.0.x'
version: '8.0.x'
projects: '**/testadapter/YamlTestAdapter.csproj'
arguments:
-c $(BuildConfiguration)
Expand All @@ -295,8 +295,8 @@ stages:
az --version
az account show
cd $(TestResultsPath)
echo dotnet test --logger trx --results-directory "$(Agent.TempDirectory)" --logger:"trx;LogFileName=$(TestRunTrxFileName)" --logger:"console;verbosity=normal" --filter "$(TestFilter)" "$(LocalBinOutputPath)/$(BuildConfiguration)/net7.0/Azure.AI.CLI.TestAdapter.dll"
dotnet test --logger trx --results-directory "$(Agent.TempDirectory)" --logger:"trx;LogFileName=$(TestRunTrxFileName)" --logger:"console;verbosity=normal" --filter "$(TestFilter)" "$(LocalBinOutputPath)/$(BuildConfiguration)/net7.0/Azure.AI.CLI.TestAdapter.dll"
echo dotnet test --logger trx --results-directory "$(Agent.TempDirectory)" --logger:"trx;LogFileName=$(TestRunTrxFileName)" --logger:"console;verbosity=normal" --filter "$(TestFilter)" "$(LocalBinOutputPath)/$(BuildConfiguration)/net8.0/Azure.AI.CLI.TestAdapter.dll"
dotnet test --logger trx --results-directory "$(Agent.TempDirectory)" --logger:"trx;LogFileName=$(TestRunTrxFileName)" --logger:"console;verbosity=normal" --filter "$(TestFilter)" "$(LocalBinOutputPath)/$(BuildConfiguration)/net8.0/Azure.AI.CLI.TestAdapter.dll"
# -----------------------------------------------------------------------------
# Archive and publish the test run backup artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: '7.0.x' # Set the desired .NET version
dotnet-version: '8.0.x' # Set the desired .NET version

- name: Set up environment variables
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/.vscode/**
**/bin/*/net6.0/*
**/bin/*/net7.0/*
**/bin/*/net8.0/*
**/obj/*
ideas/website/node_modules/**
testresults/**
2 changes: 1 addition & 1 deletion ideas/azure-ai-cli-installation-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Customer Requirements:
- Support Debian 10, 11, and 12
- Support Ubunutu 20.04 and 22.04
- Check and install Azure CLI if not present
- Check and install dotnet 7.0 if not present
- Check and install dotnet 8.0 if not present
- Check and install Python azure.ai.generative SDK if not present
- Update user's shell rc file (e.g. `$HOME/.bashrc` and/or `$HOME/.zshrc`)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
<AICLIExtensionReferencePath Condition="'$(AICLIExtensionReferencePath)' == ''">D:\src\ai-cli\src\ai\bin\Debug\net7.0</AICLIExtensionReferencePath>
<AICLIExtensionReferencePath Condition="'$(AICLIExtensionReferencePath)' == ''">D:\src\ai-cli\src\ai\bin\Debug\net8.0</AICLIExtensionReferencePath>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 10 additions & 11 deletions scripts/InstallAzureAICLIDeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ if ! command -v az &> /dev/null; then
fi
fi

# Check if dotnet 7.0 is installed
# Check if dotnet 8.0 is installed
if ! command -v dotnet &> /dev/null; then
echo "dotnet is not installed."
dotnet_version=0
else
dotnet_version=$(dotnet --version | cut -d. -f1)
fi

if [ "$dotnet_version" -eq "7" ]; then
if [ "$dotnet_version" -eq "8" ]; then
dotnet_version=$(dotnet --version)
echo "dotnet $dotnet_version is already installed."
else
echo "Installing dotnet 7.0..."
echo "Installing dotnet 8.0..."

# Update the package list
sudo apt-get update
Expand All @@ -60,11 +60,10 @@ else
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
elif [[ "$CHECK_VERSION" == "22.04" ]]; then
# We don't need to install the Microsoft package signing key for Ubuntu 22.04; in fact, if we do, `dotnet tool` doesn't work
echo "Ubuntu 22.04 detected. Skipping Microsoft package signing key installation."
# wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
# sudo dpkg -i packages-microsoft-prod.deb
# rm packages-microsoft-prod.deb
# Install the Microsoft package signing key for Ubuntu 20.04
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
else
echo "Unsupported Ubuntu version: $CHECK_VERSION"
exit 1
Expand Down Expand Up @@ -96,13 +95,13 @@ else
exit 1
fi

# Install dotnet 7.0 runtime
# Install dotnet 8.0 runtime
sudo apt-get update
sudo apt-get install -y dotnet-sdk-7.0
sudo apt-get install -y dotnet-sdk-8.0

# Check if the installation was successful
if [ $? -ne 0 ]; then
echo "Failed to install Dotnet 7.0."
echo "Failed to install Dotnet 8.0."
exit 1
fi
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
Expand Down
17 changes: 15 additions & 2 deletions src/ai/ai-cli.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>ai</AssemblyName>
<SelfContained>false</SelfContained>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<Configurations>Debug;Release</Configurations>
Expand All @@ -27,6 +26,20 @@
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<PropertyGroup Condition="'$(PublishProfile)' == '' or '$(PublishProfile)' == 'fdd'">
<SelfContained>false</SelfContained>
</PropertyGroup>

<!-- Self-contained deployment not yet finished/tested ... -->
<PropertyGroup Condition="'$(PublishProfile)' == 'scd'">
<SelfContained>true</SelfContained>
<IsTrimmable>true</IsTrimmable>
<PublishAot>true</PublishAot>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<LinkerDescriptor>linker.xml</LinkerDescriptor>
</PropertyGroup>

<PropertyGroup>
<LocalBinOutputPath Condition="'$(LocalBinOutputPath)' == '' And '$(LocalBuildSDKBinPath)' != ''">$(LocalBuildSDKBinPath)</LocalBinOutputPath>
<LocalBinOutputPath Condition="'$(LocalBinOutputPath)' == ''">bin</LocalBinOutputPath>
Expand Down
56 changes: 52 additions & 4 deletions src/ai/commands/dev_command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,24 @@ private void DoDevShell()
Console.WriteLine();

var runCommand = RunCommandScriptToken.Data().GetOrDefault(_values);
var processOutput = string.IsNullOrEmpty(runCommand)
? ProcessHelpers.RunShellCommandAsync(fileName, arguments, env, null, null, null, false).Result
: ProcessHelpers.RunShellCommandAsync(runCommand, env, null, null, null, false).Result;

var exitCode = processOutput.ExitCode;
// var processOutput = string.IsNullOrEmpty(runCommand)
// ? ProcessHelpers.RunShellCommandAsync(fileName, arguments, env, null, null, null, false).Result
// : ProcessHelpers.RunShellCommandAsync(runCommand, env, null, null, null, false).Result;

// var exitCode = processOutput.ExitCode;

UpdateFileNameArguments(runCommand, ref fileName, ref arguments, out var deleteWhenDone);

var process = ProcessHelpers.StartProcess(fileName, arguments, env, false);
process.WaitForExit();

if (!string.IsNullOrEmpty(deleteWhenDone))
{
File.Delete(deleteWhenDone);
}

var exitCode = process.ExitCode;
if (exitCode != 0)
{
Console.WriteLine("\n(ai dev shell) FAILED!\n");
Expand All @@ -133,6 +146,41 @@ private void DoDevShell()
}
}

private static void UpdateFileNameArguments(string runCommand, ref string fileName, ref string arguments, out string? deleteTempFileWhenDone)
{
deleteTempFileWhenDone = null;

if (!string.IsNullOrEmpty(runCommand))
{
var isSingleLine = !runCommand.Contains('\n') && !runCommand.Contains('\r');
if (isSingleLine)
{
var parts = runCommand.Split(new char[] { ' ' }, 2);
var inPath = FileHelpers.FileExistsInOsPath(parts[0]) || (OS.IsWindows() && FileHelpers.FileExistsInOsPath(parts[0] + ".exe"));

var filePart = parts[0];
var argsPart = parts.Length == 2 ? parts[1] : null;

fileName = inPath ? filePart : fileName;
arguments = inPath ? argsPart : (OS.IsLinux()
? $"-lic \"{runCommand}\""
: $"/c \"{runCommand}\"");

Console.WriteLine($"Running command: {runCommand}\n");
}
else
{
deleteTempFileWhenDone = Path.GetTempFileName() + (OS.IsWindows() ? ".cmd" : ".sh");
File.WriteAllText(deleteTempFileWhenDone, runCommand);

fileName = OS.IsLinux() ? "bash" : "cmd.exe";
arguments = OS.IsLinux() ? $"-lic \"{deleteTempFileWhenDone}\"" : $"/c \"{deleteTempFileWhenDone}\"";

Console.WriteLine($"Running script:\n\n{runCommand}\n");
}
}
}

private void DisplayBanner(string which)
{
if (_quiet) return;
Expand Down
8 changes: 8 additions & 0 deletions src/ai/linker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="System.Diagnostics.DiagnosticSource">
<type fullname="System.Diagnostics.ActivitySource">
<method name=".ctor" />
</type>
</assembly>
</linker>
2 changes: 1 addition & 1 deletion src/common/common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Azure.AI.CLI.Common</AssemblyName>
</PropertyGroup>
Expand Down
15 changes: 10 additions & 5 deletions src/extensions/helper_functions_extension/FileHelperFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ public static bool DirectoryCreate(string directoryName)
return true;
}

[HelperFunctionDescription("List files; lists all files regardless of name; only in current directory")]
public static string FindAllFilesInCurrentDirectory()
{
return FindAllFilesMatchingPattern("*");
}

[HelperFunctionDescription("List files; lists all files regardless of name")]
public static string FindAllFiles()
[HelperFunctionDescription("List files; lists all files regardless of name; searches current directory and all sub-directories")]
public static string FindAllFilesRecursively()
{
return FindFilesMatchingPattern("**/*");
return FindAllFilesMatchingPattern("**/*");
}

[HelperFunctionDescription("List files; lists files matching pattern")]
public static string FindFilesMatchingPattern([HelperFunctionParameterDescription("The pattern to search for; use '**/*.ext' to search sub-directories")] string pattern)
[HelperFunctionDescription("List files; lists all files matching pattern; searches current directory, and if pattern includes '**', all sub-directories")]
public static string FindAllFilesMatchingPattern([HelperFunctionParameterDescription("The pattern to search for; use '**/*.ext' to search sub-directories")] string pattern)
{
var files = FileHelpers.FindFiles(".", pattern);
return string.Join("\n", files);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyName>Azure.AI.CLI.Extensions.HelperFunctions</AssemblyName>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Azure.AI.Details.Common.CLI.Extensions.HelperFunctions</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/template_extension/TemplateFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static bool ListTemplates(string? templateFilter, string? languageFilter)
var groups = GetFilteredTemplateGroups(templateFilter, languageFilter);
if (groups.Count == 0)
{
Console.WriteLine($"No matching templates found\n");
ConsoleHelpers.WriteLineError($"No matching templates found\n");
groups = GetTemplateGroups();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyName>Azure.AI.CLI.Extensions.Templates</AssemblyName>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Azure.AI.Details.Common.CLI.Extensions.Templates</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyName>Azure.AI.CLI.Extensions.HelperFunctions.Test</AssemblyName>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Azure.AI.Details.Common.CLI.Extensions.HelperFunctions.Test</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Loading

0 comments on commit 39691ad

Please sign in to comment.