-
Notifications
You must be signed in to change notification settings - Fork 827
Test templates #6086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test templates #6086
Conversation
...rojectTemplates/Microsoft.Extensions.AI.Templates.InegrationTests/AichatwebTemplatesTests.cs
Outdated
Show resolved
Hide resolved
a71ffcc
to
00ef90e
Compare
I'm surprised it worked, but it did. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a few questions.
test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/TestBase.cs
Outdated
Show resolved
Hide resolved
<ItemGroup> | ||
<!--#if (IsOllama) | ||
<PackageReference Include="OllamaSharp" Version="${OllamaSharpVersion}" /> | ||
#elif (IsGHModels) | ||
<PackageReference Include="OpenAI" Version="${OpenAIVersion}" /> | ||
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="${MicrosoftExtensionsAIVersion}" /> | ||
#elif (IsAzureAiFoundry) | ||
<PackageReference Include="Azure.AI.Projects" Version="${AzureAIProjectsVersion}" /> | ||
<PackageReference Include="Azure.AI.OpenAI" Version="${AzureAIOpenAIVersion}" /> | ||
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="${MicrosoftExtensionsAIVersion}" /> | ||
#else --> | ||
<PackageReference Include="Azure.AI.OpenAI" Version="${AzureAIOpenAIVersion}" /> | ||
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="${MicrosoftExtensionsAIVersion}" /> | ||
<!--#endif --> | ||
<!--#if (UseManagedIdentity) --> | ||
<PackageReference Include="Azure.Identity" Version="${AzureIdentityVersion}" /> | ||
<!--#endif --> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.2" /> | ||
<PackageReference Include="Microsoft.Extensions.AI" Version="${MicrosoftExtensionsAIVersion}" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="${MicrosoftSemanticKernelCoreVersion}" /> | ||
<PackageReference Include="PdfPig" Version="${PdfPigVersion}" /> | ||
<PackageReference Include="System.Linq.Async" Version="${SystemLinqAsyncVersion}" /> | ||
<!--#if (UseAzureAISearch) | ||
<PackageReference Include="Azure.Search.Documents" Version="${AzureSearchDocumentsVersion}" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AzureAISearch" Version="${MicrosoftSemanticKernelConnectorsAzureAISearchVersion}" /> | ||
#endif --> | ||
</ItemGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the .in
file included in the snapshot? Does this mean that the .in
file gets included in the generated project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question which I can't answer :)
I guess it does...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MackinnonBuck - yes, the *.in file is included in the generated content.
I followed the steps the test performs:
PS D:\Development> dotnet new install D:\Development\dotnet-extensions\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\src\ChatWithCustomData --debug:custom-hive C:\Users\user\AppData\Local\Temp\hkgl3nh4.eq4\home
The following template packages will be installed:
D:\Development\dotnet-extensions\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\src\ChatWithCustomData
Success: D:\Development\dotnet-extensions\src\ProjectTemplates\Microsoft.Extensions.AI.Templates\src\ChatWithCustomData installed the following templates:
Template Name Short Name Language Tags
--------------- ---------- -------- -------------
AI Chat Web App aichatweb [C#] Common/AI/Web
PS D:\Development> pushd C:\Users\user\AppData\Local\Temp\TemplateEngine.Tests\test
PS C:\Users\user\AppData\Local\Temp\TemplateEngine.Tests\test> dotnet new aichatweb -n aichatweb -o aichatweb --debug:custom-hive C:\Users\user\AppData\Local\Temp\hkgl3nh4.eq4\home --no-update-check
The template "AI Chat Web App" was created successfully.
PS C:\Users\user\AppData\Local\Temp\TemplateEngine.Tests\test> ls .\aichatweb\
Directory: C:\Users\user\AppData\Local\Temp\TemplateEngine.Tests\test\aichatweb
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 14/03/2025 11:17 AM Components
d----- 14/03/2025 11:17 AM Properties
d----- 14/03/2025 11:17 AM Services
d----- 14/03/2025 11:17 AM wwwroot
-a---- 14/03/2025 11:17 AM 889 aichatweb.csproj
-a---- 14/03/2025 11:17 AM 2053 aichatweb.csproj.in
-a---- 14/03/2025 11:17 AM 178 appsettings.Development.json
-a---- 14/03/2025 11:17 AM 202 appsettings.json
-a---- 14/03/2025 11:17 AM 2678 Program.cs
-a---- 14/03/2025 11:17 AM 1194 README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's probably because the test is looking at files directly inside the repo and treating them as template content. This ignores any preprocessing of such content that happens as part of building the Microsoft.Extensions.AI.Templates
project (for example, here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to block the PR on it, but it might be good to figure out how to fix that for the future. Maybe the Microsfot.Extensions.AI.Templates
project copies its content to an output folder at build time, and then that's what gets used by the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, your comment didn't show up for me until I refreshed the page. If you produce a NuGet package from Microsfot.Extensions.AI.Templates
, I'm guessing there's no .in
file there, right? That's what I've seen from my local testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leveraging [template testing infra](https://github.com/dotnet/templating/wiki/Templates-Testing-Tooling) for a basic test of the AI template. More tests can be added later. During a test the template is getting installed locally and then a new app is created, which is then gets snapshot-verified using Verify tooling. For the local devex, it is very much worth installing [Verify DiffEngineTray](https://github.com/VerifyTests/DiffEngine/blob/main/docs/tray.md) to approve all incoming snapshots (for the initial iteration). It is also possible that git block staging the snapshot files due to line ending issues, and "git config core.safecrlf false" could be used as a way to work around this.
Leveraging template testing infra for a basic test of the AI template. More tests can be added later.
During a test the template is getting installed locally and then a new app is created, which is then gets snapshot-verified using Verify tooling.
For the local devex, it is very much worth installing Verify DiffEngineTray to approve all incoming snapshots (for the initial iteration).
It is also possible that git block staging the snapshot files due to line ending issues, and
git config core.safecrlf false
could be used as a jailbreak card.Microsoft Reviewers: Open in CodeFlow