1

I have created a Visual Studio solution containing all the required design elements (like master pages and user controls) that I would be re-using in all my new applications. I created a visual studio template using (File -> Export Template) and I am able to create new solution based on it.

I have changed the assembly name, solution id with new Guid. The problem is with Feature Id. I noticed that even when I changed the feature id and id (in feature.xml) with new Guid it still overwrites the existing feature already deployed on the farm instead of creating a new feature.

Please advise whether it's possible to re-use a visual studio template with existing features.

2 Answers 2

2

The below worked for me.

  1. Create a visual studio solution and add Module (Module1) which would create a new Feature (Feature1).
  2. Create required User Controls and master page under Module1 and modify Elements.xml file accordingly.
  3. Deploy the solution to verify whether master page and user controls are working fine.
  4. Create new visual studio solution and open the solution from windows explorer.
  5. Copy Module1 from existing visual studio solution to new visual studio solution and add any references required for the project.
  6. Navigate to the new visual studio solution and click on "Show All Files" button in solutions explorer to display all hidden files.
  7. Right click on Module1 and click "Include In Project" which would create a new Feature (Feature1). Make necessary changes to the feature and deploy which would create a new feature in "Feature" folder.
0

Please refer to Ibraheem blog he has an excellent feature that he can share with us. http://www.youvegotcode.com/2014/11/error-feature-with-id-is-not-installed.html

Error: In Visual Studio 2013 or 2010 when you are trying to deploy your feature (using the default Active Deployment) and your SharePoint farm has a multiple servers, then it will fail to deploy the solution & activate the features, and will throw the following error message: “Error occurred in deployment step ‘Activate Features’: feature with ID '{guid}' is not installed in this farm, and cannot be added to this scope.” Also, the solution will show ‘Not Deployed’ in Farm solutions page in Central Administration

Reason: This is a bug in Visual Studio 2013 (see this post for same issue in VS2010). Visual Studio uses the Microsoft.SharePoint.Administration.SPSolution.DeployLocal() method that can only deploy/activate features on local machine when its the only server in farm.

Objective: To preserve the way the developer works. Developer need not worry about target environment (number of servers in farm for example), and should not need to run PowerShell commands every time the code changes. Developer should only use the Build > Deploy menu item in Visual Studio as usual, and the deploy process should figure it out how to install the package & features.

Solution: Its actually a workaround until Microsoft fix with their Visual Studio. The idea is to replace Visual Studio feature activation action by a PowerShell script that will make sure the feature was installed then activated properly. The script is to be called as a post-deployment command.

Tested with: Visual Studio 2013 Update 2, and SharePoint 2013 Visual Web Part

How To Use: 1- Make sure that path of your project does not contain spaces Example: “D:\TeamShared\iibraheem\PSproj\PSproj”

2- If you are using Visual Studio 2013 to target SharePoint 2013: Make sure that you set the ‘Site Url’ property of your project to target a SharePoint 2013 site that has the new SP2013 UI. The reason is that your Visual Studio 2013 visual web part will NOT work for a SharePoint 2013 site that has a SP2010 UI (coming from a SP2010 db upgrade). 3-Adding the script

3.1-Add the script file (Example: PostDeployScript_Feature.ps1) to project at root level

3.2- Edit script file: set the parameters $Url and $FeatureName. $FeatureName is in the format of ‘ProjectName_FeatureName’ (without quotes) and has nothing to do with feature title 2.

4- Go to project properties > SharePoint tab

4.1-Set Active Deployment Configuration to ‘No Activation’

4.2- Paste the below command in Post-Deployment Command Line box:

Show Then Hide PS console (recommended): %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell "start-process powershell.exe -ArgumentList '$(ProjectDir)PostDeployScript_Feature.ps1'" Keep visible PS console (for debugging): %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell "start-process powershell.exe -ArgumentList '-NoExit', '$(ProjectDir)PostDeployScript_Feature.ps1'"

5- Save the project

6- Build > Deploy

Check PowerShell console window:
It stays visible if ‘-NoExit’ parameter used, otherwise it will close automatically:
1
  • please add the main points from the article as links tend to go down after a while. Commented Nov 15, 2016 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.