-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add x-generate-msbuild-props command (#705)
* Add x-activate-msbuildprops command which is activate except it can only generate msbuild properties, and never downloads the content. * Fix espidf activation. * Rename activate-msbuildprops to generate-msbuildprops and the switch to --out only for that command. * Rename x-generate-msbuildprops to x-generate-msbuild-props * Avoid redundantly passing in 'session' values to Activation.activate, as requested by #705 (comment)
- Loading branch information
1 parent
4bc93c8
commit 522aa94
Showing
13 changed files
with
194 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Activation } from '../../artifacts/activation'; | ||
import { buildRegistryResolver, resolveDependencies } from '../../artifacts/artifact'; | ||
import { i } from '../../i18n'; | ||
import { session } from '../../main'; | ||
import { showArtifacts } from '../artifacts'; | ||
import { Command } from '../command'; | ||
import { error } from '../styling'; | ||
import { Json } from '../switches/json'; | ||
import { MSBuildProps } from '../switches/msbuild-props'; | ||
import { Project } from '../switches/project'; | ||
import { WhatIf } from '../switches/whatIf'; | ||
|
||
export class GenerateMSBuildPropsCommand extends Command { | ||
readonly command = 'generate-msbuild-props'; | ||
readonly aliases = []; | ||
seeAlso = []; | ||
argumentsHelp = []; | ||
whatIf = new WhatIf(this); | ||
project: Project = new Project(this); | ||
msbuildProps: MSBuildProps = new MSBuildProps(this, 'out'); | ||
json : Json = new Json(this); | ||
|
||
get summary() { | ||
return i`Generates MSBuild properties for an activation without downloading anything for a project`; | ||
} | ||
|
||
get description() { return ['']; } | ||
|
||
override async run() { | ||
if (!this.msbuildProps.active) { | ||
error(i`generate-msbuild-props requires --msbuild-props`); | ||
return false; | ||
} | ||
|
||
const projectManifest = await this.project.manifest; | ||
|
||
if (!projectManifest) { | ||
error(i`Unable to find project in folder (or parent folders) for ${session.currentDirectory.fsPath}`); | ||
return false; | ||
} | ||
|
||
const projectResolver = await buildRegistryResolver(session, projectManifest.metadata.registries); | ||
const resolved = await resolveDependencies(session, projectResolver, [projectManifest], 3); | ||
|
||
// print the status of what is going to be activated. | ||
if (!await showArtifacts(resolved, projectResolver, {})) { | ||
error(i`Unable to activate project`); | ||
return false; | ||
} | ||
|
||
const activation = new Activation(session); | ||
for (const artifact of resolved) { | ||
if (!await artifact.artifact.loadActivationSettings(activation)) { | ||
session.channels.error(i`Unable to activate project.`); | ||
return false; | ||
} | ||
} | ||
|
||
const content = activation.generateMSBuild(); | ||
await this.msbuildProps.value?.writeUTF8(content); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.