Skip to content
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
43 changes: 43 additions & 0 deletions src/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,49 @@ Follow Semantic Versioning: `MAJOR.MINOR.PATCH[-PRERELEASE]`
- Uninstall first: `dotnet tool uninstall -g Microsoft.Agents.A365.DevTools.Cli`
- Use `.\install-cli.ps1` which handles this automatically

**"a365: The term 'a365' is not recognized" after installation**

This happens when `%USERPROFILE%\.dotnet\tools` is not in your PATH environment variable.

**Quick Fix (Current Session Only):**
```powershell
# Add to current PowerShell session
$env:PATH += ";$env:USERPROFILE\.dotnet\tools"
a365 --version # Test it works
```

**Permanent Fix (Recommended):**
```powershell
# Add permanently to user PATH
$userToolsPath = "$env:USERPROFILE\.dotnet\tools"
$currentUserPath = [Environment]::GetEnvironmentVariable("Path", "User")

if ($currentUserPath -like "*$userToolsPath*") {
Write-Host "Already in user PATH: $userToolsPath" -ForegroundColor Green
} else {
[Environment]::SetEnvironmentVariable("Path", "$currentUserPath;$userToolsPath", "User")
Write-Host "Added to user PATH permanently" -ForegroundColor Green
Write-Host "Restart PowerShell/Terminal for this to take effect" -ForegroundColor Yellow
}
```

After permanent fix:
1. Close and reopen PowerShell/Terminal
2. Run `a365 --version` to verify

**Alternative: Manual PATH Update (Windows)**
1. Open System Properties → Environment Variables
2. Under "User variables", select "Path" → Edit
3. Add new entry: `C:\Users\YourUsername\.dotnet\tools`
4. Click OK and restart terminal

**Linux/Mac:**
Add to `~/.bashrc` or `~/.zshrc`:
```bash
export PATH="$PATH:$HOME/.dotnet/tools"
```
Then run: `source ~/.bashrc` (or `source ~/.zshrc`)

---

## Contributing
Expand Down
30 changes: 20 additions & 10 deletions src/Microsoft.Agents.A365.DevTools.Cli/Commands/ConfigCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ public static Command CreateCommand(ILogger logger, string? configDir = null, IC
var directory = configDir ?? Services.ConfigService.GetGlobalConfigDirectory();
var command = new Command("config", "Configure Azure subscription, resource settings, and deployment options\nfor a365 CLI commands");

if (wizardService != null)
{
command.AddCommand(CreateInitSubcommand(logger, directory, wizardService));
}

// Always add init command - it supports both wizard and direct import (-c option)
command.AddCommand(CreateInitSubcommand(logger, directory, wizardService));
command.AddCommand(CreateDisplaySubcommand(logger, directory));

return command;
}

private static Command CreateInitSubcommand(ILogger logger, string configDir, IConfigurationWizardService wizardService)
private static Command CreateInitSubcommand(ILogger logger, string configDir, IConfigurationWizardService? wizardService)
{
var cmd = new Command("init", "Interactive wizard to configure Agent 365 with Azure CLI integration and smart defaults")
{
Expand Down Expand Up @@ -86,8 +83,11 @@ private static Command CreateInitSubcommand(ILogger logger, string configDir, IC
return;
}

// Save to target location
var outputJson = JsonSerializer.Serialize(importedConfig, new JsonSerializerOptions { WriteIndented = true });
// CRITICAL: Only serialize static properties when saving to a365.config.json
// This prevents dynamic properties (e.g., agentBlueprintId, managedIdentityPrincipalId)
// from being written to the static config file
var staticConfig = importedConfig.GetStaticConfig();
var outputJson = JsonSerializer.Serialize(staticConfig, new JsonSerializerOptions { WriteIndented = true });
await File.WriteAllTextAsync(configPath, outputJson);

// Also save to global if saving locally
Expand Down Expand Up @@ -124,15 +124,25 @@ private static Command CreateInitSubcommand(ILogger logger, string configDir, IC
}
}

// If no config file specified, run wizard
if (wizardService == null)
{
logger.LogError("Wizard service not available. Use -c option to import a config file, or run from full CLI.");
context.ExitCode = 1;
return;
}

try
{
// Run the wizard with existing config
var config = await wizardService.RunWizardAsync(existingConfig);

if (config != null)
{
// Save the configuration
var json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
// CRITICAL: Only serialize static properties (init-only) to a365.config.json
// Dynamic properties (get/set) should only be in a365.generated.config.json
var staticConfig = config.GetStaticConfig();
var json = JsonSerializer.Serialize(staticConfig, new JsonSerializerOptions { WriteIndented = true });

// Save to primary location (local or global based on flag)
await File.WriteAllTextAsync(configPath, json);
Expand Down
Loading
Loading