搞SharePoint开发的兄弟姐妹们对STSDev应该非常熟悉了,STSDev的最新版本为1.3,本文所指的Bug就是针对该版本STSDev 1.3 ,May 8 2008)(这个Bug也1.2版本中仍然存在,叶伟民同志曾经解决了1.2老版本中的这个问题但未指明原因在何处,本文简单探索一下原因)。STSDev1.3的操作主界面(我进行了简单的控件对齐调整)如下图:

 

  我在使用中文版操作系统(Win03)创建基于Visual Studio 2008的相关SharePoint解决方案时发现了该Bug,即:如果选择“Visual Studio 2005 with .NET 3.0” 或“Visual Studio 2008 with .NET 3.0 ”,都能成功生成相应的解决方案。但如果选择“Visual Studio 2008 with .NET 3.5 ”就会报错,错误如下图:

  好在STSDev是开源project,就不需要Reflector帮忙啦。经过调试,在代码文件SolutionBuilder.cs中:

  到这儿,你可能会认为是路径问题后,其实不然

 
  1. if (SolutionBuilder.SolutionVersionType == SolutionVersionTypeEnum.VS2008_35) {   
  2.        
  3.     engine = new Engine(Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\..\Microsoft.NET\Framework\v3.5");   
  4. }   
  5. else {   
  6.     engine = new Engine(Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\..\Microsoft.NET\Framework\v2.0.50727");   
  7. }  

  真正的原因在于

  在.NET3.5版本中,MSBuild构造器有所改变。Visual Studio 2008 将安装 .NET Framework 3.5,后者包括两个预定义的工具集:一个用于 .NET Framework 2.0,另一个用于 .NET Framework 3.5。但Visual Studio 2008 中有三个 .NET Framework 版本可用,分别是:.NET Framework 2.0(随附于Visual Studio 2005)、.NET Framework 3.0(随附于 Windows Vista)、.NET Framework 3.5(随附于 Visual Studio 2008)。因此在生成项目的时候,指定Framework 的目标版本非常重要!MSBuild 使用 $(MSBuildToolsPath) 属性来查找目标和任务。MSBuild 3.5 工具集在生成此项目之前,必须先将 $(MSBuildToolsPath) 解析为 MSBuild 3.5 的安装位置。

  因此我们需要明确引用两个程序集:Microsoft.Build.Engine、Microsoft.Build.Framework。更多微软官方介绍详情请点这里参考。

  最简单有效的经济办法:新建一个config配置文件,名称为“stsdev.exe.config”,用任一文本编辑器打开,写入内容如下:

 
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <configuration>  
  3.   <runtime>  
  4.     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
  5.       <dependentAssembly>  
  6.         <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>  
  7.         <bindingRedirect oldVersion="0.0.0.0-3.4.0.0" newVersion="3.5.0.0"/>  
  8.       </dependentAssembly>  
  9.       <dependentAssembly>  
  10.         <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>  
  11.         <bindingRedirect oldVersion="0.0.0.0-3.4.0.0" newVersion="3.5.0.0"/>  
  12.       </dependentAssembly>  
  13.     </assemblyBinding>  
  14.   </runtime>  
  15. </configuration>  

  修改并保存后,把stsdev.exe.config复制到STSDev的目录下,使该文件与stsdev.exe在同一目录下即可!

  为了方便后来人,可以直接下载stsdev.exe.config (680.00 bytes)放到本地相应目录即可!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5