Giter Site home page Giter Site logo

gillissm / thecodeattic.helix.powershellprojectcreator Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 55 KB

Sitecore Helix is a set of overall design principles and conventions for Sitecore development, put forth by Sitecore in hopes of providing the community a path toward standardized solution development. As part of this principle there are expected file system and Visual Studio Solution structures that are to be used, which can be time intensive to setup. This script is meant to be a utility to ease this setup process.

License: GNU General Public License v3.0

PowerShell 100.00%
sitecore-helix sitecore powershell-module sitecore-tool

thecodeattic.helix.powershellprojectcreator's Introduction

TheCodeAttic.Helix.PowerShellProjectCreator

Helix (http://helix.sitecore.net) is a set of overall design principles and conventions for Sitecore development, put forth by Sitecore in hopes of providing the community a path toward standardized solution development.

As part of this principle there are expected file system and Visual Studio Solution structures that are to be used, which can be time intensive to setup. This script is meant to be a utility to ease this setup process.

Setup and Configure from Script

To make adaption as easy as possible I've simplified setup to the following three steps for you:

  1. Open PowerShell command prompt as Admin.
  2. Change the directory to a working/temporary location
  3. Enter the following
(Invoke-WebRequest -UseBasicParsing -Uri https://raw.githubusercontent.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator/master/ProjectCreatorEasyInstall.ps1).Content | Out-File "ProjectCreatorEasyInstall.ps1"

.\ProjectCreatorEasyInstall.ps1

Setup and Use the Simple Manual Process

As an alternate to the above, you can pull the script from GitHub and run load it into Package Manager Console each time you need it with the following steps:

  1. Download (https://github.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator/blob/master/Helix.ProjectCreator.psm1) to your local system in the manner that suits your workflow the best.
  2. Each time you wish to leverage the module in Visual Studio you will need to enter the following in the Package Manager Console
Import-Module "C:\MyFiles\THelix.ProjectCreator.psm1"

Setup and Configure the Manual Way

OR you could download and configure the module manually each time (this is what ProjectCreatorEasyInstall.ps1 does for you.)

  1. Go to C:\Users<CURRENT USER DIRECTORY>\Documents\WindowsPowerShell\Modules
  2. Create a new folder called "Helix.ProjectCreator"
  3. Download (https://github.com/gillissm/TheCodeAttic.Helix.PowerShellProjectCreator/blob/master/Helix.ProjectCreator.psm1) into the above directory
  4. Go up a level in the file system, should be at C:\Users<CURRENT USER DIRECTORY>\Documents\WindowsPowerShell\
  5. Open (or create) NuGet_profile.ps1
  6. Add the following
Import-Module Helix.ProjectCreator
  1. Each time you run Visual Studio the module will be available to use in the Package Console Manager

Using the Script to Manage Helix Solution

Because the script leverages the native DTE Interface of Visual Studio is can be used to create new solutions, as well as modify existing solutions without any additional tweaks to the code.

Confirm Module Has Loaded

The following will allow you to confirm that the module is accessible for usage. This check is most helpful the first time one has used it after leveraging the easy install script.

Get-Module Helix.ProjectCreator -ListAvailable

Create a new Helix Solution

  1. Open Visual Studio as Admin
  2. Open the Package Manager Console
  3. Create a new Helix based solution by running Invoke-VisualStudioSolution
    • Include the parameter '-SolutionName', this will be the name of the VS solution as well the name given to the directory create for the solution
    • Include the parameter '-DirectoryPath', this is the fully qualified path to the parent directory the solution should be created at
Invoke-VisualStudioSolution -SolutionName HelixAttic.Sample -DirectoryPath C:\Code\git-TheCodeAttic\

Add a new module to a solution

  1. Open Visual Studio as Admin
  2. Open your Solution
  3. Open the Package Manager Console
  4. Add new module by running Invoke-NewModule
    • Set parameter -ModuleName to the name of the module/component, this should NOT include the full namespace, as this will be generated automatcially based on solution name
    • Select a value for -Layer from the provided list (Feature, Foundation, Project) depending on need
    • Optionally include the -UseUnicorn or -UseTDS flag to setup the corresponding serialization requirements
Invoke-NewModule -ModuleName PageContent -Layer Feature -UseUnicorn

Add a new empty module to a solution

In addition to creating a project with folders and NuGet references, the script can add a blank or empty project with the given name to the solution by including the flag -CreateEmptyProject.

Invoke-NewModule -ModuleName PlaceHolder -Layer Foundation -CreateEmptyProject

See the module file for a listing of all optional parameters, including the ability to set a specific Sitecore version.

Other Cmdlets of interest

Invoke-SerializationProject

Call this to setup Unicorn or TDS project for a given module. When calling, be sure to include the full project name (with namespace).

Invoke-SerializationProject -ProjectName HelixAttic.Sample.Foundation.PlaceHolder -UseUnicorn

Invoke-CreateNewModuleProject

Call this to add an empty project to the solution for a layer, this is the same as calling Invoke-NewModule with the 'CreateEmptyProject' flag.

Now go create some awesome Sitecore code with confidence!

thecodeattic.helix.powershellprojectcreator's People

Contributors

gillissm avatar scottgillis-paragoninc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

thecodeattic.helix.powershellprojectcreator's Issues

Property "FullName" cannot be found on the object

When I'm running the Invoke-NewModule command in Visual Studio 2019, I'm getting the following error in the NuGet console:

Get-VisualStudioTemplate : The property 'FullName' cannot be found on this object. Verify that the property exists.
At C:\Users\Kenneth
McAndrew\Documents\WindowsPowerShell\Modules\TheCodeAttic.Helix.PowerShellProjectCreator\TheCodeAttic.Helix.PowerShellProjectCreator.psm1:1686
char:29

  • ... platePath = Get-VisualStudioTemplate -TemplateName 'EmptyWebApplicati ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-VisualStudioTemplate

The property 'FullName' cannot be found on this object. Verify that the property exists.

Unit Test Create

Provide flag to Invoke-NewModule to indicate a Unit Test project should be created.

Module fails in VS 2019

Scott,

I tried using the module for testing it out with Sitecore 9.3 on VS 2019. Ran into below issue

Invoke-NewModule -ModuleName Phani.Feature.AzureADGraph -Layer Feature -Verbose
`Invoke-CreateModuleProject : Value does not fall within the expected range.
At C:\Users\phani\Documents\WindowsPowerShell\Modules\Helix.ProjectCreator\Helix.ProjectCreator.psm1:1518 char:25

  • ... $projName = Invoke-CreateModuleProject -ModuleName $ModuleName -Layer ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CreateModuleProject

Value does not fall within the expected range.`

After doing a little more digging, found the issue is with below line. I searched online and MS documents for some clue but couldn't find anything that can help me resolve.
function Invoke-CreateModuleProject { . . . . . . **$sp.SubProject.Object.AddFromTemplate($ModuleProjectTemplate, $modulePath, $projName)**

Thanks
Venkata Phani Abburi

NuGet References

Provide a method that allows for listing specific NuGet packages to be installed.

Empty Project Flag

Include a flag to Invoke-NewModule which will signify the project should not have references or other file structure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.