Skip to content

Commit

Permalink
Add new optional argument to create .net7 project
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski committed Aug 3, 2022
1 parent c27703a commit b19e6ee
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
args.push('--arg:Framework', cpUtils.wrapArgInQuotes('net7.0'));
}

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

await setLocalAppSetting(context, context.projectPath, azureWebJobsStorageKey, '', MismatchBehavior.Overwrite);
}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/dotnet/executeDotnetTemplateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function getFramework(context: IActionContext, workingDirectory: string |
}

// Prioritize "LTS", then "Current", then "Preview"
const netVersions: string[] = ['6.0', '5.0', '3.1'];
const netVersions: string[] = ['7.0', '6.0', '5.0', '3.1'];
const semVersions: SemVer[] = netVersions.map(v => semVerCoerce(v) as SemVer);

let pickedVersion: SemVer | undefined;
Expand Down
311 changes: 163 additions & 148 deletions tools/JsonCli/.azure-pipelines/main.yml
Original file line number Diff line number Diff line change
@@ -1,152 +1,167 @@
jobs:
- job: Windows
pool:
name: VSEngSS-MicroBuild2019-1ES
variables:
SrcPath: 'tools/JsonCli/src'
ProjectPath: '$(SrcPath)/Microsoft.TemplateEngine.JsonCli.csproj'
SigningProjectPath: '$(SrcPath)/Signing.csproj'
NugetConfigPath: '$(SrcPath)/nuget.config'
DropPath: '$(build.artifactstagingdirectory)/drop'
steps:
- task: ms-vseng.MicroBuildTasks.30666190-6959-11e5-9f96-f56098202fef.MicroBuildSigningPlugin@2
displayName: 'Install Signing Plugin'
inputs:
signType: '$(SignType)'
env:
TeamName: 'AzureTools'

- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1.x'
inputs:
version: 3.1.x

- task: UseDotNet@2
displayName: 'Use .NET sdk 5.0.x'
inputs:
version: 5.0.x

- task: UseDotNet@2
displayName: 'Use .NET sdk 6.0.x'
inputs:
version: 6.0.x

- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '$(ProjectPath)'
feedsToUse: config
nugetConfigPath: '$(NugetConfigPath)'

- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
projects: '$(ProjectPath)'
arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
displayName: 'dotnet publish 3.1'
inputs:
command: publish
publishWebProjects: false
projects: '$(ProjectPath)'
arguments: '--configuration $(BuildConfiguration) --framework netcoreapp3.1 --no-build'
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: 'dotnet publish 5.0'
inputs:
command: publish
publishWebProjects: false
projects: '$(ProjectPath)'
arguments: '--configuration $(BuildConfiguration) --framework net5.0 --no-build'
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: 'dotnet publish 6.0'
inputs:
command: publish
publishWebProjects: false
projects: '$(ProjectPath)'
arguments: '--configuration $(BuildConfiguration) --framework net6.0 --no-build'
zipAfterPublish: false
modifyOutputPath: false

- task: DeleteFiles@1
displayName: 'Delete unneeded publish files'
inputs:
SourceFolder: '$(SrcPath)'
Contents: |
bin/**/publish/**/*.exe
bin/**/publish/**/*.pdb
# Run before we build the signing project, because we don't want to analyze that
- task: securedevelopmentteam.vss-secure-development-tools.build-task-roslynanalyzers.RoslynAnalyzers@3
displayName: 'Run Roslyn Analyzers'
continueOnError: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')
inputs:
msBuildCommandline: '$(Agent.ToolsDirectory)\dotnet\dotnet.exe build "$(Build.SourcesDirectory)\$(ProjectPath)" --configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
displayName: 'dotnet restore signing'
inputs:
command: restore
projects: '$(SigningProjectPath)'
feedsToUse: config
nugetConfigPath: '$(NugetConfigPath)'

- task: DotNetCoreCLI@2
displayName: 'dotnet build signing'
inputs:
projects: '$(SigningProjectPath)'
arguments: '--configuration $(BuildConfiguration)'

- task: CopyFiles@2
displayName: 'Copy Files to Staging'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)/tools/JsonCli/src/'
Contents: 'bin/**/publish/**'
TargetFolder: '$(DropPath)'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(DropPath)'
condition: succeededOrFailed()

- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
displayName: 'Run BinSkim'
inputs:
InputType: Basic
AnalyzeTarget: '$(DropPath)\*.dll;$(DropPath)\*.exe'
continueOnError: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@2
displayName: 'Verify Signed Files'
inputs:
TargetFolders: '$(DropPath)'

- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
displayName: 'Publish Security Analysis Logs'
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
displayName: 'Post Analysis'
inputs:
AllTools: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')
inputs:
sourceScanPath: tools/JsonCli # Scope only to the JSON CLI tool, since that's all this build is for
- job: Windows
pool:
name: VSEngSS-MicroBuild2019-1ES
variables:
SrcPath: "tools/JsonCli/src"
ProjectPath: "$(SrcPath)/Microsoft.TemplateEngine.JsonCli.csproj"
SigningProjectPath: "$(SrcPath)/Signing.csproj"
NugetConfigPath: "$(SrcPath)/nuget.config"
DropPath: "$(build.artifactstagingdirectory)/drop"
steps:
- task: ms-vseng.MicroBuildTasks.30666190-6959-11e5-9f96-f56098202fef.MicroBuildSigningPlugin@2
displayName: "Install Signing Plugin"
inputs:
signType: "$(SignType)"
env:
TeamName: "AzureTools"

- task: UseDotNet@2
displayName: "Use .NET Core sdk 3.1.x"
inputs:
version: 3.1.x

- task: UseDotNet@2
displayName: "Use .NET sdk 5.0.x"
inputs:
version: 5.0.x

- task: UseDotNet@2
displayName: "Use .NET sdk 6.0.x"
inputs:
version: 6.0.x

- task: UseDotNet@2
displayName: "Use .NET sdk 7.0.x"
inputs:
version: 7.0.x

- task: DotNetCoreCLI@2
displayName: "dotnet restore"
inputs:
command: restore
projects: "$(ProjectPath)"
feedsToUse: config
nugetConfigPath: "$(NugetConfigPath)"

- task: DotNetCoreCLI@2
displayName: "dotnet build"
inputs:
projects: "$(ProjectPath)"
arguments: "--configuration $(BuildConfiguration)"

- task: DotNetCoreCLI@2
displayName: "dotnet publish 3.1"
inputs:
command: publish
publishWebProjects: false
projects: "$(ProjectPath)"
arguments: "--configuration $(BuildConfiguration) --framework netcoreapp3.1 --no-build"
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: "dotnet publish 5.0"
inputs:
command: publish
publishWebProjects: false
projects: "$(ProjectPath)"
arguments: "--configuration $(BuildConfiguration) --framework net5.0 --no-build"
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: "dotnet publish 6.0"
inputs:
command: publish
publishWebProjects: false
projects: "$(ProjectPath)"
arguments: "--configuration $(BuildConfiguration) --framework net6.0 --no-build"
zipAfterPublish: false
modifyOutputPath: false

- task: DotNetCoreCLI@2
displayName: "dotnet publish 7.0"
inputs:
command: publish
publishWebProjects: false
projects: "$(ProjectPath)"
arguments: "--configuration $(BuildConfiguration) --framework net7.0 --no-build"
zipAfterPublish: false
modifyOutputPath: false

- task: DeleteFiles@1
displayName: "Delete unneeded publish files"
inputs:
SourceFolder: "$(SrcPath)"
Contents: |
bin/**/publish/**/*.exe
bin/**/publish/**/*.pdb
# Run before we build the signing project, because we don't want to analyze that
- task: securedevelopmentteam.vss-secure-development-tools.build-task-roslynanalyzers.RoslynAnalyzers@3
displayName: "Run Roslyn Analyzers"
continueOnError: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')
inputs:
msBuildCommandline: '$(Agent.ToolsDirectory)\dotnet\dotnet.exe build "$(Build.SourcesDirectory)\$(ProjectPath)" --configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
displayName: "dotnet restore signing"
inputs:
command: restore
projects: "$(SigningProjectPath)"
feedsToUse: config
nugetConfigPath: "$(NugetConfigPath)"

- task: DotNetCoreCLI@2
displayName: "dotnet build signing"
inputs:
projects: "$(SigningProjectPath)"
arguments: "--configuration $(BuildConfiguration)"

- task: CopyFiles@2
displayName: "Copy Files to Staging"
inputs:
SourceFolder: "$(system.defaultworkingdirectory)/tools/JsonCli/src/"
Contents: "bin/**/publish/**"
TargetFolder: "$(DropPath)"
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: drop"
inputs:
PathtoPublish: "$(DropPath)"
condition: succeededOrFailed()

- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
displayName: "Run BinSkim"
inputs:
InputType: Basic
AnalyzeTarget: '$(DropPath)\*.dll;$(DropPath)\*.exe'
continueOnError: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@2
displayName: "Verify Signed Files"
inputs:
TargetFolders: "$(DropPath)"

- task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2
displayName: "Publish Security Analysis Logs"
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
displayName: "Post Analysis"
inputs:
AllTools: true
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')

- task: ComponentGovernanceComponentDetection@0
displayName: "Component Detection"
condition: eq(variables['ENABLE_COMPLIANCE'], 'true')
inputs:
sourceScanPath: tools/JsonCli # Scope only to the JSON CLI tool, since that's all this build is for

trigger: none

Expand Down

0 comments on commit b19e6ee

Please sign in to comment.