2017-06-24 41 views
18

我正在玩弄对Roslyn的一些更改,但不幸的是,当我运行VisualStudioSetup.Next时,即使未修改的解决方案也会崩溃,尝试加载MS程序集时出错。所以我做了一些简单的更改,并用新版本替换了我的机器现有的二进制文件和配置文件。在C:/Program Files (x86)/MSBuild/bin and Windows/Microsoft.NET/Framework64进行了更改。用新的Roslyn构建替换c#编译器

替换CSC,VBCSCompiler,DLL和配置文件会导致csc.exe在任何构建上抛出错误。它抱怨该清单指定了一个不同版本的CodeAnalysis.CSharp DLL。它没有给出文件或名称的路径。我用新版本替换了在上述文件夹中找到的配置和DLL。我需要什么文件才能取代它才能正常工作?

我为CSC的所有实例搜索了整个驱动器,并确保所有的配置都指定了DLL的新版本,所以我不知道现在在哪里看。

我知道可以将参数传递给MSBuild,或者向csproj文件添加一个节来为编译器二进制文件指定一个目录,但是我希望获得胜利。

编辑:所以我决定只更改我的版本的版本号。通过VS中的组装属性执行它会导致构建失败。我试图使用MSBuild,但它在每个单个项目中都会失败,并且出现此错误:

"F:\Git\Repos\roslyn\src\Compilers\CSharp\csc\csc.csproj" (default target) (1) -> 

F:\Git\Repos\roslyn\build\Targets\Versions.props(42,5): 

error MSB4184: The expression ""1".Substring(3)" cannot be evaluated. 

startIndex cannot be larger than length of string. 

Parameter name: startIndex F:\Git\Repos\roslyn\src\Compilers\CSharp\csc\csc.csproj] 

它在VS中生成良好。

的MSBuild PARAMS:/p:OfficialBuild=true /p:BuildNumber=1.3.1.60616 /p:Configuration=Release

+3

你在做什么听起来有点脏。 –

+0

@MathiasLykkegaardLorenzen当然。我的团队喜欢拉一些恶作剧,使他们难以扭转。这就是为什么我不喜欢修改构建参数来使用新的编译器。 –

+0

你试图达到什么听起来很有趣,但请让我们知道你的目标是什么。您是否试图替换Visual Studio安装的csc.exe?所以,当你在Visual Studio中编译更新后的csc,exe文件被使用? –

回答

1

在Visual Studio 2017年当前分钟实验实例来替换编译器。所需版本是v15.3或更高版本。并且有必要安装Roslyn.Compilers.Extension.vsix而不是VisualStudioSetup.Next。从DotNet Roslyn GitHub库的文件

精确信息如下:

CompilerExtension: this project can be found inside the Compilers folder from the Solution Explorer, and builds Roslyn.Compilers.Extension.vsix . This deploys a copy of the command line compilers that are used to do actual builds in the IDE. It only affects builds triggered from the Visual Studio experimental instance it's installed into, so it won't affect your regular builds. Note that if you install just this, the IDE won't know about any language features included in your build. If you're regularly working on new language features, you may wish to consider building both the CompilerExtension and VisualStudioSetup projects to ensure the real build and live analysis are synchronized.

说明VisualStudioSetup.Next明确指出它的局限性和预期使用,这是固定IDE错误:

VisualStudioSetup.Next: this project can be found inside the VisualStudio folder from the Solution Explorer, and builds Roslyn.VisualStudio.Setup.vsix. In theory, it contains code to light up features for the next version of VS (Dev16), but currently hasn't been updated for that since Dev15/VS2017 shipped. If you're working on fixing an IDE bug, this is the project you want to use.

如果计划是在Visual Studio 2017的默认实例中替换Roslyn编译器,而不是以下操作:

  1. 关闭Visual Studio 2017的所有实例。
  2. 双击Roslyn.Compilers.Extension.vsix软件包,然后升级安装扩展。这次它应该在默认实例中可用。

以上步骤也可以应用于Visual Studio构建工具。

请注意 - 如果您构建并使用未发布的代码,那么即使在安装步骤期间它也会出现问题。