I have been working in a development environment and deploying my custom web part features from Visual Studio directly by just hitting F5. I now need a way to deploy features separately to a test environment and would like to know the best way to go about this. I know there is an "Install-SPFeature" command but it seems to require a feature.xml file. In my Visual Studio project I have a .feature file and a .template.xml file but no plain feature.xml file. How do I generate this feature.xml file to use the Install-SPFeature command or is there an even better way to deploy single features to a site?
You need the
.wsp file that contains the features. You can create with Visual Studio by right clicking the Project and hit on Publish option.
First af all, open a SharePoint Management Shell. You have to add the Solution to SharePoint with this command:
Add-SPSolution -LiteralPath $SolutionPath
Then, install the solution:
$Url = "http://urltoinstall" $SolutionToInstall = Get-SPSolution -Identity "yourSolutionName.wsp" Install-SPSolution -Identity $SolutionToInstall -WebApplication $Url -GACDeployment -Force
-WebApplication parameter if you want deploy globally.
Finally install the feature you want with this command
$FeatureName = "YourFeatureName" Install-SPFeature $FeatureName -Force $FeatureActivate = Get-SPFeature $FeatureName Enable-SPFeature -Identity $FeatureName -Url $Url -Force
Hope this solves your question