|
| 1 | +# Work on CLU cmdlets |
| 2 | + |
| 3 | +### Prerequsites |
| 4 | + |
| 5 | +Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html). |
| 6 | + |
| 7 | +Note, after done, run `dnvm list` command to check the 'coreclr' runtime is installed with right version of `1.0.0-rc1-final`. If not, run `dnvm install 1.0.0-rc1-final -r coreclr -a x64 -p`. Remember always use `-p` flag, so the selection can persist. |
| 8 | + |
| 9 | +### Project Artifacts |
| 10 | + |
| 11 | +CLUPackages require some additional files to direct generation of indexing, and to provide shortcuts when files are installed. These files can be copied from the Profile project and updated for each package. |
| 12 | + |
| 13 | +* Content\azure.lx, configures command dispatch, here are the changeable fields in this file |
| 14 | + |
| 15 | + | Field | Value | |
| 16 | + | ------------- |:-------------:| |
| 17 | + | Modules | Assembly name of cmdlets assembly | |
| 18 | + | NounPrefix | ‘AzureRm’ The part of the cmdlet noun to remove in clu commands| |
| 19 | + |
| 20 | +* Content\package.cfg, configures index generation on install, here are the changeable fields |
| 21 | + |
| 22 | + | Field | Value | |
| 23 | + | ------------- |:-------------:| |
| 24 | + | CommandAssemblies | File name of cmdlets assembly(ies) | |
| 25 | + | NounPrefix | ‘AzureRm’ The part of the cmdlet noun to remove in clu commands| |
| 26 | + | NounFirst | if true, the verb comes at the end of the command (e.g. azure resource get)| |
| 27 | + |
| 28 | +* Tools\Azure.Bat: contains the batch file command for running cmdlets in the clu. Do not change |
| 29 | +* \<modulename\>.nuspec.template, which contains nuspec format metadata about the package – the base temaplate is in tools\clu\Microsoft.Azure.Commands.nuspec.template. |
| 30 | + * %PackageId% - replace with the module name (Microsoft.Azure.Commands.\<rp-name\>) |
| 31 | + * %PackageTitle% Title of the cmdlet package in nuget |
| 32 | + * %PackageVersion%, %ReferenceFiles%,%SourceFiles%,%ContentFiles% - Filled in by build tool |
| 33 | + * %PackageSummary% - Summary field in nuget ui |
| 34 | + * %PackageDescription% - Log description in package ui |
| 35 | + * Almost all cmdlets packages should add a dependency to Microsoft.Azure.Commands.Profile package |
| 36 | + |
| 37 | +* Ensure that project.json is set to expose a command entrypoint: `"compilationOptions": {"emitEntryPoint": true}` |
| 38 | +* Ensure that the project implements at least one console entry point |
| 39 | + ```c# |
| 40 | + public class EntryStub |
| 41 | + { |
| 42 | + public static void Main(string[] args) |
| 43 | + { |
| 44 | + // empty entry point |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + ``` |
| 49 | + |
| 50 | +### Package Creation and Testing |
| 51 | + 2 options |
| 52 | + * Run `<repo-root>\tools\CLU\SetupEnv.bat` which build and generate all cmdlet packages and deploy to under `<repo root>\drop` folder. When you have a clean environment, you should always do this first. |
| 53 | + * Run `<repo-root>\tools\CLU\BuildCmdlet` <name like: Microsoft.Azure.Commands.Profile>", this will build and refresh an individual cmdlet package. |
| 54 | + |
| 55 | +Once you are done with #1, in the same command window, you can type "azure help" to explore and run cmdlets. |
| 56 | + |
| 57 | +To debug, set environment variable of `DebugCLU` to "1"(#1 should set it up already). When you run any command, you will see a prompt telling you to attach debugger. |
| 58 | + |
| 59 | +To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, you should see subfolders for "osx" and "ubuntu", copy the folder to your target machine, and run the "azure.sh" inside. Make sure set execution permission using `chmod +x azure.sh clurun` |
| 60 | + |
| 61 | +(All of those are subject to change, contact yugangw or adxsdkdev for any questions) |
| 62 | + |
| 63 | +### Quick introductions on cmdlets |
| 64 | + * Run commands using the ‘azure’ prefix, cmdlet nouns, and cmdlet verbs, for example, `azure environment get` maps to the cmdlet `Get-AzureRmEnvironment` |
| 65 | + * Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `azure subscription get –SubscriptionName “name of subscription"` |
| 66 | + * To log in, 3 options |
| 67 | + * login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `azure account add` |
| 68 | + * login with user and password, this works on org-id w/o 2fa enforced, example: `azure account add --Username [email protected] --Password password1` |
| 69 | + * login as service principal. Example: `azure account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>` |
0 commit comments