Skip to content
Codeblack edited this page Mar 12, 2017 · 1 revision

A NuGet-package is now available to easily add the build-scripts to a solution.

This package will add the build-scripts to a 'BuildScripts' solution-folder. If a solution-folder with that name already exists, no changes are made during installation. The 'Add-BuildScripts' function is also made available to the Package Manager Console. Use this function to add the build-scripts to a different folder or force the build-scripts to be added to an existing 'BuildScripts' solution-folder.

Add-BuildScripts

This function is available in the Package Manager Console after the package is installed. It adds the build-scripts to a solution. If the FolderName parameter is not provided, the default folder-name 'BuildScripts' is used. If the solution-folder already exists, no changes are made. In this case, specify a different FolderName or use the Force parameter to add the build-scripts to the existing folder. Use the Overwrite parameter to overwrite any existing build-scripts with the original build-scripts from the package.

Parameters

FolderName

Defines the name of the solution-folder to which the build-scripts are added.

Force

Specifies that build-scripts should be added, even if the solution-folder already exists. Existing files are not overwritten.

Overwrite

Specifies that existing build-scripts should be overwritten.

Examples

Add build-scripts to the solution using the default solution-folder

Add-BuildScripts

Add build-scripts to the solution using a different folder-name

Add-BuildScripts -FolderName ADifferentSolutionFolder

Add (missing) build-scripts to the solution using the default solution-folder, which already exists

Add-BuildScripts -Force

Add (missing) build-scripts to the solution using a different folder-name, which already exists

Add-BuildScripts -FolderName ADifferentSolutionFolder -Force

Overwrite existing build-scripts in the default solution-folder

Add-BuildScripts -Overwrite

Overwrite existing build-scripts in a different solution-folder

Add-BuildScripts -FolderName ADifferentSolutionFolder -Overwrite

Known issues

  • If a different folder-name is used, and a solution-folder with the default folder-name ('BuildScripts') does not exist, this folder will be added (with the build-scripts) when the solution is opened.

    Cause: Since this is a solution-level package, the init.ps1 script is called each time the solution is opened. This is one of the reasons the package doesn't add the build-scripts if the solution-folder already exists.

    Workaround: Only use a different folder-name if the default folder-name is already used. Or uninstall the package after installation; this will leave the build-scripts in the solution (See the next known issue).

    Possible solution: Look for the build-scripts in any solution-folder; assume that's the desired location, and use it instead of the default.

  • The solution-folder and the build-scripts are not removed when the package is uninstalled.

    Cause: Since this is a solution-level package, there is no script that runs when the package is uninstalled.

    Workaround: Remove the solution-folder and build-scripts manually.

    Possible solution: None.

  • The build-scripts are not updated when the package is updated.

    Cause: I have not yet found a safe way to detect if any manual changes where made to the build-scripts. If so, I wouldn't want to overwrite those changes. Since there is no script that runs when the package is uninstalled, I can't remove the files as part of the uninstall-process.

    Workaround: To replace all build-scripts with new versions, execute 'Add-BuildScripts -Overwrite' in the Package Manager Console. To replace only some scripts, delete those scripts, then execute 'Add-BuildScripts -Force'.

    Possible solution: Determine (or rather, make an educated guess) if there was a previous package installed, and compare the contents of the current files with those of that package.

Clone this wiki locally