You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2021-06-02-Setup-Internal-PowerShell-Repository.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ tags:
11
11
12
12
toc: true
13
13
header:
14
-
teaser: "/assets/images/PowerShell_Logo.png"
14
+
teaser: "/assets/images/PowerShell_Logo.png"
15
15
---
16
16
17
17
## PowerShell repositories
@@ -20,9 +20,9 @@ If you follow my blog you probably know my [GitHub](https://github.com/PsCustomO
20
20
21
21
In my posts I often talked about [PowerShell Gallery](https://pscustomobject.github.io/powershell/tips/PowerShell-Restore-Default-Repository/) which you probably already used to install a module released by Microsoft or other developers.
22
22
23
-
Both are great tools when sharing code with a large audience over the internet, GitHub Private repositories are scope of this article, but a large chunk of my work involves developing *modules* that me and my colleagues user internally for automation purposes. These modules usually leverage technologies that are available only in my work environment and sometimes implement functions that would not have much sense outside my company.
23
+
Both are great tools when sharing code with a large audience over the internet, GitHub Private repositories are scope of this article, but a large chunk of my work involves developing _modules_ that me and my colleagues user internally for automation purposes. These modules usually leverage technologies that are available only in my work environment and sometimes implement functions that would not have much sense outside my company.
24
24
25
-
One of the main issues we faced when initially started development of our own modules is ease of distribution to other team members for this reason we've setup internal **NuGet** repositories which can be used an *internal* PowerShell Gallery.
25
+
One of the main issues we faced when initially started development of our own modules is ease of distribution to other team members for this reason we've setup internal **NuGet** repositories which can be used an _internal_ PowerShell Gallery.
26
26
27
27
## Required tools
28
28
@@ -32,11 +32,11 @@ Here's what you will need to follow this article and setup your own PowerShell r
32
32
- The ASP.NET and web development workload installed [here's](https://docs.microsoft.com/en-us/visualstudio/install/modify-visual-studio?view=vs-2019) a guide on how to modify an existing Visual Studio installation in case you don't have the appropriate workload installed already
33
33
- A server running a supported copy of **Windows Server** I am using Windows 2019 but 2016 will do just fine
34
34
35
-
**Note:** If you do not have or cannot install Visual Studio at the end of the post I have posted a link to my [GitHub Repository](https://github.com/PsCustomObject/Nuget-PowerShell-Repository/tree/main/NuGetRepository/NuGetRepository)
35
+
**Note:** If you do not have or cannot install Visual Studio at the end of the post I have posted a link to my [GitHub Repository](https://github.com/PsCustomObject/Nuget-PowerShell-Repository/tree/main/NuGetRepository/NuGetRepository)
36
36
37
37
## Create the Visual Studio Project
38
38
39
-
Once all requirements are in place open Visual Studio and create a project using the *ASP.Web Application (Visual C#)* template.
39
+
Once all requirements are in place open Visual Studio and create a project using the _ASP.Web Application (Visual C#)_ template.
Application name is not important just avoid *NuGet* as this would create a conflict with one of the *packages* we need to install as part of the dependencies, in my example I've used **NuGetRepository** but it can really be anything
51
+
Application name is not important just avoid _NuGet_ as this would create a conflict with one of the _packages_ we need to install as part of the dependencies, in my example I've used **NuGetRepository** but it can really be anything
@@ -78,29 +78,29 @@ In the *NuGetRepository* window select the *Broswe* tab and search for package *
78
78
79
79
Keep I am using the latest stable release available at the time of this writing but you can select a different version of the package suiting your needs.
80
80
81
-
This step will take some time, depending on your connection speed, and a window showing you changes to the solution and asking your confirmation will appear in which case simply click on the *Ok* button.
81
+
This step will take some time, depending on your connection speed, and a window showing you changes to the solution and asking your confirmation will appear in which case simply click on the _Ok_ button.
82
82
83
-
Once the installation step is complete I highly recommend to change the build type from *Debug*, default for new projects, to *Release* as this will disable all debug logging that is otherwise enabled for the solution.
83
+
Once the installation step is complete I highly recommend to change the build type from _Debug_, default for new projects, to _Release_ as this will disable all debug logging that is otherwise enabled for the solution.
Once this is done go to *Build / Build Solution* menu, or press F6 if you're lazy like me, to *package* together all files making up the solution.
90
+
Once this is done go to _Build / Build Solution_ menu, or press F6 if you're lazy like me, to _package_ together all files making up the solution.
91
91
92
-
This will create a folder structure, under the path previously specified, containing all files required by the solution. Project path is visible in the **Properties** window under the *Project Folder* field
92
+
This will create a folder structure, under the path previously specified, containing all files required by the solution. Project path is visible in the **Properties** window under the _Project Folder_ field
**Note:** By default solution will be build under the C:\Users\username\source\repos\AppName\AppName\ path
99
+
**Note:** By default solution will be build under the C:\Users\username\source\repos\AppName\AppName\ path
100
100
101
101
## Install required Server Components
102
102
103
-
Once the solution has been build in Visual Studio move on the server that will be hosting the repository and launch the following cmdlet from an elevated PowerShell session to install required *IIS* components
103
+
Once the solution has been build in Visual Studio move on the server that will be hosting the repository and launch the following cmdlet from an elevated PowerShell session to install required _IIS_ components
Once all components are in place copy the solution files to a directory on the server with the default being *C:\inetpub\wwwroot*. Path is not really import and could be anything you'd like, I will just stick with the default.
118
+
Once all components are in place copy the solution files to a directory on the server with the default being _C:\inetpub\wwwroot_. Path is not really import and could be anything you'd like, I will just stick with the default.
119
119
120
-
As a refrence here's how the content of my application folder looks like on my test server
120
+
As a reference here's how the content of my application folder looks like on my test server
@@ -126,7 +126,7 @@ As a refrence here's how the content of my application folder looks like on my t
126
126
127
127
### Update Web.Config configuration file
128
128
129
-
The **web.config** file is located in the project root folder, assuming default path this will be *C:\inetpub\wwwroot\NuGetRepository*, open it with a text editor and under the **\<system.web\>** section you should see line similar the following (actual .Net Framework version could vary)
129
+
The **web.config** file is located in the project root folder, assuming default path this will be _C:\inetpub\wwwroot\NuGetRepository_, open it with a text editor and under the **\<system.web\>** section you should see line similar the following (actual .Net Framework version could vary)
130
130
131
131
```xml
132
132
<system.web>
@@ -147,11 +147,11 @@ Comment out or delete one of the instances of **\<compilation\>** tag so that re
147
147
</system.web>
148
148
```
149
149
150
-
**Note:** If the *web.config* file is not updated when opening the IIS Application an *Internal Server Error* message will be displayed an application won't work.
150
+
**Note:** If the _web.config_ file is not updated when opening the IIS Application an _Internal Server Error_ message will be displayed an application won't work.
151
151
152
152
## Deploy Application to IIS
153
153
154
-
We can finally deploy the *NuGet* application to IIS to do so open **IIS Manager / Expand <ServerName> / Sites** right-click on Default Web Site and select **Add Application**
154
+
We can finally deploy the _NuGet_ application to IIS to do so open **IIS Manager / Expand <ServerName> / Sites** right-click on Default Web Site and select **Add Application**
@@ -174,7 +174,7 @@ To test the configuration point your browser to **http://localhost/Nuget** which
174
174
175
175
### Configure Package Directory
176
176
177
-
In the default configuration packages are stored under the same path where the application lives in the *Packages* directory, in our example *C:\inetpub\wwwroot\Nuget\Packages*. This can be changed in the *web.config* configuration file via the following tag
177
+
In the default configuration packages are stored under the same path where the application lives in the _Packages_ directory, in our example _C:\inetpub\wwwroot\Nuget\Packages_. This can be changed in the _web.config_ configuration file via the following tag
178
178
179
179
```xml
180
180
<!--
@@ -186,23 +186,23 @@ In the default configuration packages are stored under the same path where the a
186
186
187
187
### Configure Repository API Key
188
188
189
-
Up to this point the repository is ready and can be used to *download* packages from it but if we need to *upload* data, in our example PowerShell modules, to it we would need some form of authentication which in NuGet is accomplished through an API key.
189
+
Up to this point the repository is ready and can be used to _download_ packages from it but if we need to _upload_ data, in our example PowerShell modules, to it we would need some form of authentication which in NuGet is accomplished through an API key.
190
190
191
-
First of all generate a unique API key, I generally use a GUID generated via *New-Guid* cmdlet, open the *web.config* file and update the **apiKey** value as in the following example
191
+
First of all generate a unique API key, I generally use a GUID generated via _New-Guid_ cmdlet, open the _web.config_ file and update the **apiKey** value as in the following example
192
192
193
193
```xml
194
194
<!--
195
-
Determines if an Api Key is required to push\delete packages from the server.
195
+
Determines if an Api Key is required to push\delete packages from the server.
196
196
-->
197
197
<addkey="requireApiKey"value="true" />
198
-
<!--
198
+
<!--
199
199
Set the value here to allow people to push/delete packages from the server.
200
200
NOTE: This is a shared key (password) for all users.
201
201
-->
202
202
<addkey="apiKey"value="<GUID VALUE>" />
203
203
```
204
204
205
-
If you want to disable authentication all together you can simply set the **requireApiKey** to *false*.
205
+
If you want to disable authentication all together you can simply set the **requireApiKey** to _false_.
0 commit comments