Skip to content
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

Push Framework argument for .net7.0 #3273

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export class DotnetProjectCreateStep extends ProjectCreateStepBase {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ejizba Just wanted to check with you on this-- so I should only have to pass --arg: Framework net7.0 on project creation since that is when the .csproj is generated and that's where Framework is actually replacing TargetFrameworkValue.

On a FunctionCreate, assumedly the project is already created with the appropriate .csproj file.

Yes that is correct

const functionsVersion: string = 'v' + majorVersion;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @liliankasem

For Alex's context, this is a new change by Lilian to the .NET isolated templates. PR here: Azure/azure-functions-templates#1240. Basically, in the past the isolated worker only really supported one .NET version at a time (or at least only one we cared about for the sake of templates). Now, they support net48, net6.0, and net7.0 all at once which is why a new parameter was introduced. If the arg is not passed, it will currently default to net6.0.

Also - it's important to note that the version of the dotnet cli being used to create the project does not necessarily match the version of the project. I can have all three versions installed on my machine but I should still be able to pick which one I use for my project.

const projTemplateKey = nonNullProp(context, 'projectTemplateKey');
await executeDotnetTemplateCommand(context, version, projTemplateKey, context.projectPath, 'create', '--identity', identity, '--arg:name', cpUtils.wrapArgInQuotes(projectName), '--arg:AzureFunctionsVersion', functionsVersion);
const args = ['--identity', identity, '--arg:name', cpUtils.wrapArgInQuotes(projectName), '--arg:AzureFunctionsVersion', functionsVersion];
// defaults to net6.0 if there is no targetFramework
args.push('--arg:Framework', cpUtils.wrapArgInQuotes(context.workerRuntime?.targetFramework));

await executeDotnetTemplateCommand(context, version, projTemplateKey, context.projectPath, 'create', ...args);

await setLocalAppSetting(context, context.projectPath, azureWebJobsStorageKey, '', MismatchBehavior.Overwrite);
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/cpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export namespace cpUtils {
/**
* Ensures spaces and special characters (most notably $) are preserved
*/
export function wrapArgInQuotes(arg: string | boolean | number): string {
export function wrapArgInQuotes(arg?: string | boolean | number): string {
arg ??= '';
return typeof arg === 'string' ? quotationMark + arg + quotationMark : String(arg);
}
}