Creating a SharePoint package is easy enough with Visual Studio but each time you restart it, the package location used previously is replaced with the default location of the current user’s Documents folder.
To save a few seconds from my life I decided to write a PowerShell script to build and package the solution, meaning I no longer have to specify the publish location whenever Visual Studio is restarted.
I’m using Visual Studio 2013 and SharePoint 2013
& "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "C:\Projects\TestProject\TestSolution.csproj" /t:rebuild;package
Write-Host "Copying TestSolution.wsp to Packages folder" -NoNewLine
Copy-Item -Confirm:$false "C:\Projects\TestProject\bin\Debug\TestSolution.wsp" C:\Packages\
Write-Host " - done." |
& "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "C:\Projects\TestProject\TestSolution.csproj" /t:rebuild;package
Write-Host "Copying TestSolution.wsp to Packages folder" -NoNewLine
Copy-Item -Confirm:$false "C:\Projects\TestProject\bin\Debug\TestSolution.wsp" C:\Packages\
Write-Host " - done."
The script shown has been simplified for this post and is easy enough to parametrise to allow you to specify different SharePoint projects to package.
Anyway, back to the main reason for this post.
After doing the above and running the script the following error was generated:
C:\Projects\TestProject\TestSolution.csproj(88,3): error MSB4019: The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Continue reading →