Visual Studio Solution Example to download and base any Content Hub Development on. It supports Intellisense, Sync of scripts, Debugging and Unit-Testing e.g. for Content Hub Scripts and Azure Functions. It also stores External Page Components. Overall it provides guidance on how to best structure a Visual Studio Solution for Content Hub Projects and therefore accelerates Customers and Partners.
Clone the Repository and get yourself a content hub environment.
Check the documentation for the lates nuget package source: https://docs.stylelabs.com/contenthub/4.1.x/content/integrations/web-sdk/get-started.html
You need a User to connect with your Visual Studio solution to the Content Hub environment so you can sync your scripts or unit test against your environment
- Open the Manage View.
- Open the Users App
- Add a User and give a name e.g.: "CommandlineUser"
- Assign required (all) modules.
- Switch to “User groups“ Tab and click "Add to user group"
- Search for "Superusers", select checkbox and confirm with "Select" Button
- You might see the error message "Missing from Policy combination: Superusers". This can be ignored
- Save Changes
You need to create a Token to authenticate when setting the password of the user via the API using e.g. Postman.
- Open Users App and click the Key Icon of your user
- Click the "New token" button
- Copy the shown token.
- Open Postman
- Send the following Request
Request Url: [YOUR-CONTENT-HUB-URL]/api/[USER-ID]/setpasword
e.g. https://abc.stylelabs.com/api/account/12345/setpassword
Headers:
x-auth-token [THE_TOKEN_CREATED]
Content-Type application/json
Body:
{"password":"[YOUR-PASSWORD]"}
Note: The User ID can be retrieved from the URL, when editing the User.
The OAuth Client is required to connect with your Visual Studio solution to the Content Hub environment so you can sync your scripts or unit test against your environment.
- Open the Mange View
- Open the "OAuth clients" app
- Create a new OAuth client
- Fill in the mandatory fields
e.g.: Name: SolutionUser Client Id: SolutionUser ClientSecret: SolutionUser Redirect Url: [YOUR-CONTENT-HUB-URL] Client Type (can stay blank) Users: [SELECT-USER-CREATED-PREVIOUSLY]
- Save the OAuth Client
Put either local.settings.json file into root of the following projects or handle via user secrets. Use the provided content and adjust user and client information accordingly. Ignore those files so they are not shared with Git Repo
Sitecore.CH.Implementation.Scripts.Tests
{
"M": {
"Host": "[YOUR-CONTENT-HUB-URL]",
"ClientId": "[YOUR-CLIENT-ID]",
"ClientSecret": "[YOUR-CLIENT-SECRET]",
"UserName": "[YOUR-USER-NAME]",
"Password": "[YOUR-PASSWORD]",
"KnownSSoRedirects": []
}
}
Sitecore.CH.Implementation.CommandLine
{
"M": {
"Host": "[YOUR-CONTENT-HUB-URL]",
"ClientId": "[YOUR-CLIENT-ID]",
"ClientSecret": "[YOUR-CLIENT-SECRET]",
"UserName": "[YOUR-USER-NAME]",
"Password": "[YOUR-PASSWORD]",
"KnownSSoRedirects": []
},
"CommandLine": {
"ScriptPush": {
"_scriptDirectoryPath": "[YOUR-REPO-PATH]\\src\\Sitecore.CH.Implementation.Scripts",
"scriptDirectoryPath": "[YOUR-REPO-PATH]\\src\\Sitecore.CH.Implementation.Scripts"
}
}
}
Note: Repository Path may look like this: "C:\repos\ContentHub\SUGCON\src\Sitecore.CH.Implementation.Scripts
Sitecore.CH.Implementation.AzFunctions
{
"M": {
"Host": "[YOUR-CONTENT-HUB-URL]",
"ClientId": "[YOUR-CLIENT-ID]",
"ClientSecret": "[YOUR-CLIENT-SECRET]",
"UserName": "[YOUR-USER-NAME]",
"Password": "[YOUR-PASSWORD]",
"KnownSSoRedirects": []
}
}
In your solution, perform a right mouse click on the Sitecore.CH.Implementation.CommandLine project.
Choose "Debug" --> "Start new Instance"
A command prompt will open that performs the magic.
If the build fails, you get an error message.
in work
in work
in work