---
title: "Ensure AppSetting"
---
Ensures a .NET application configuration file has the specified appSetting key/value pair.
DotNet::Ensure-AppSetting(
File: <text>,
Key: <text>,
Value: <text>,
[AppSettingsXPath: <text>]
);
Name | Format | Script Usage | Usage Notes |
---|---|---|---|
☆ Config file path | text | File | The file path of the configuration file, typically web.config or app.config. This argument is required. |
☆ AppSetting key | text | Key | This argument is required. |
☆ AppSetting value | text | Value | This argument is required. |
XPath for appSettings | text | AppSettingsXPath |
Note: By default, the "appSettings" section must exist in the file under the "configuration" element in order to ensure the key/value pair is present. Use the AppSettingsXPath argument to select a different element instead.
# ensures that the application is configured to use test mode for the example third-party API
DotNet::Ensure-AppSetting(
File: E:\Website\web.config,
Key: Accounts.ThirdParty.PaymentApi,
Value: https://test.example.com/api/v3
);