semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

func start --csharp from Sample doesnt work

Open kboro opened this issue 1 year ago • 1 comments

Describe the bug

`PS C:\git\semantic-kernel\samples\dotnet\KernelHttpServer> func start --csharp

MSBuild version 17.5.0+6f08c67f3 for .NET C:\git\semantic-kernel\dotnet\Directory.Build.targets : error : Could not resolve SDK "Microsoft.Build.CentralPackageVersions". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK. C:\git\semantic-kernel\dotnet\Directory.Build.targets : error : SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null. C:\git\semantic-kernel\dotnet\Directory.Build.targets : error : Unable to find package Microsoft.Build.CentralPackageVersions. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\git\semantic-kernel\dotnet\Directory.Build.targets : error : MSB4276: The default SDK resolver failed to resolve SDK "Microsoft.Build.CentralPackageVersions" because directory "C:\Program Files\dotnet\sdk\7.0.202\Sdks\Microsoft.Build.CentralPackageVersions\Sdk" did not exist. C:\git\semantic-kernel\dotnet\Directory.Build.targets : error MSB4236: The SDK 'Microsoft.Build.CentralPackageVersions/2.1.3' specified could not be found. [C:\git\semantic-kernel\samples\dotnet\KernelHttpServer\KernelHttpServer.csproj]`

Expected behavior Function is started locally

Desktop (please complete the following information):

  • OS: Windows 11
  • IDE: VS CODE

kboro avatar Mar 20 '23 16:03 kboro

Hi @kboro, you'll need .NET 7 SDK, you can download it at: https://dotnet.microsoft.com/en-us/download/dotnet/7.0

eduardogoncalves avatar Mar 20 '23 17:03 eduardogoncalves

Hi @eduardogoncalves,

Sorry I should mention about it at the beginning. Of course .NET SDK is already installed on my machine but issue still persist.

`PS C:\git\semantic-kernel> dotnet --info .NET SDK: Version: 7.0.202 Commit: 6c74320bc3

Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.202\

Host: Version: 7.0.4 Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download`

kboro avatar Mar 20 '23 19:03 kboro

Hi @kboro, as the SDK is already installed, can you clear the NuGet cache: dotnet nuget locals all --clear

Then try to build and run the function again using the following command: func start --csharp

If the issue persists, you can try to delete the bin and obj folders of the project and rebuild it. Additionally, you can try to update or reinstall the .NET SDK and Visual Studio.

eduardogoncalves avatar Mar 20 '23 20:03 eduardogoncalves

Do you also have dotnet 6?

There is an unfortunate footnote in that Azure Functions require dotnet 6 to build:

image

See https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#supported-versions

craigomatic avatar Mar 20 '23 21:03 craigomatic

When I open VSCODE with elevated permissions (runas admin) problem disappeared. Soliution works like a charm!

Thank you everyone for support!

kboro avatar Mar 21 '23 11:03 kboro