Visual Studio 2017 msbuild 包共享点

Visual Studio 2017 msbuild package sharepoint

我有一个简单的 SharePoint 2013 解决方案,我可以通过 Visual Studio 发布它 - 这将为我生成 .wsp。但是,当我尝试通过以下命令 运行 构建时:

msbuild /t:Package mySolution.sln

构建正常,但在打包过程中出现错误:

C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets(190,5): error : Could not load file or assembly 'Microsoft.VisualStudio.Modeling.Sdk.15.0, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

如果我将这个丢失的 dll 放到 C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SharePointTools 然后我会收到另一个关于另一个丢失的 dll 的错误... 我做错了什么?

看起来这是 MSBuild 问题: 1.Open 提升命令提示符

2.Navigate 到您的 SDK 工具

cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64"

  1. Sn -Vr "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Modeling.Sdk.15.0.dll"

  2. gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Modeling.Sdk.15.0.dll"

  3. 对于以下三个dll,请从第3步到第4步执行相同的操作

C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.SharePoint.dll

注意如果 Microsoft.VisualStudio.SharePoint.dll 在上面的路径中找不到,请检查
C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\SharePointTools\Microsoft.VisualStudio.SharePoint.dll

C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.SharePoint.Designers.Models.dll C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.SharePoint.Designers.Models.Features.dll

  1. 现在您可以通过 VS 命令提示符来构建您的 SharePoint 2016 解决方案。

检查 Link,它适用于 Sharepoint 2016,但同样适用于 2013:https://developercommunity.visualstudio.com/content/problem/40195/cant-use-msbuild-to-package-sharepoint-2016-soluti.html