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

Push Framework argument for .net7.0 #3273

merged 2 commits into from
Aug 4, 2022

Conversation

nturinski
Copy link
Member

@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.

Copy link
Member

@alexweininger alexweininger left a comment

Choose a reason for hiding this comment

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

Is this not a CLI bug? I feel like it should do this for us.

@@ -41,7 +41,12 @@ export class DotnetProjectCreateStep extends ProjectCreateStepBase {
}
const functionsVersion: string = 'v' + majorVersion;
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];
if (/net7.[0-9]/.test(projTemplateKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to just pass the projTemplateKey? I think it's designed to mimic the targetframework, although you might need to remove "isolated" maybe - checkout dotnetUtils for relevant code. In any case, this logic needs to be more generic to also support net48 and other frameworks moving forward

@@ -41,7 +41,12 @@ 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

@@ -41,7 +41,12 @@ export class DotnetProjectCreateStep extends ProjectCreateStepBase {
}
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.

@nturinski
Copy link
Member Author

For reference, our tests have been creating csproj files this way forever:

protected async initializeTestFolder(testFolder: string): Promise<void> {
        await super.initializeTestFolder(testFolder);
        await AzExtFsExtra.writeFile(path.join(testFolder, 'test.csproj'), `<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>${this._targetFramework}</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="${this._isIsolated ? 'Microsoft.Azure.Functions.Worker.Sdk' : 'Microsoft.NET.Sdk.Functions'}" Version="1.0.0" />
    </ItemGroup>
</Project>`);
    }

So I think adding the target framework for all versions shouldn't break anything. Also tried with v3 and it doesn't seem to find the new argument.

@nturinski nturinski merged commit 2fc0c51 into main Aug 4, 2022
@nturinski nturinski deleted the nat/net7 branch August 4, 2022 18:38
@microsoft microsoft locked and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants