脚本#和编译器问题 [英] Script# and compiler problems

查看:115
本文介绍了脚本#和编译器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2010和Script#上遇到了一个非常奇怪的问题,大多数时候我都可以重新创建.

I've just come across a pretty strange problem with VS2010 and Script#, which most of the time I am able to re-create.

在我的简单场景中,我的解决方案中有2个项目;一个标准的Asp.Net MVC2 Web应用程序和一个Script#jQuery类库.我创建了一个带有静态方法的静态类(归为[Imported]),其目的是可以将代码中的此类映射到外部Javascript库,如文档中所述.

In my simple scenario I have 2 projects in my solution; a standard Asp.Net MVC2 Web Application, and a Script# jQuery Class Library. I created a static class (attributed with [Imported]) with a static method on it, the intention being that I can map this class in code to an external Javascript library, as described in the documentation.

但是,似乎每当我使用[IgnoreNamespace]装饰这样的类以实现此目标时,项目都会停止成功编译,但不会向我提供任何有关失败原因的反馈(错误窗口中没有错误,对于例子).要摆脱这两者都不容易,因为Visual Studio似乎已经进入了永不失败的状态.删除类和项目文件并不能解决问题,也无法重新启动Visual Studio.我要让VS成功构建项目的唯一方法是完全删除该项目,创建一个新项目,然后将文件重新添加回去,至少可以这么讨厌.

However, it seems that whenever I decorate such a class with [IgnoreNamespace] to achieve this goal, the project stops successfully compiling but doesn't give me any feedback as to why it's failing (no errors in the error window, for example). It's not easy to get rid of either, as Visual Studio seems to get into a permanent state of not build failure; removing the classes and project files doesn't solve it, nor restarting visual studio. The only way I can get VS to build the project successfully is to delete the project entirely, create a new one then add the files back in, which is annoying to say the least.

使用详细的构建输出设置,我得到以下信息:

With a verbose build output setting, I get the following:

项目"e:\ project \ local \ ScriptSharpDemo \ Scripts \ Scripts.csproj"中的文件"C:\ Program Files(x86)\ ScriptSharp \ v1.0 \ ScriptSharp.targets"中的目标"AfterCompile"(目标编译"取决于它): 任务"ScriptCompilerTask" 执行任务"ScriptCompilerTask"完成-失败. 在项目"Scripts.csproj"中完成构建目标"AfterCompile"-失败.

Target "AfterCompile" in file "C:\Program Files (x86)\ScriptSharp\v1.0\ScriptSharp.targets" from project "e:\project\local\ScriptSharpDemo\Scripts\Scripts.csproj" (target "Compile" depends on it): Task "ScriptCompilerTask" Done executing task "ScriptCompilerTask" -- FAILED. Done building target "AfterCompile" in project "Scripts.csproj" -- FAILED.

..这并不能告诉我很多东西.

.. which doesn't tell me whole lot.

曾经有几次我设法创建了这种类型的类,然后成功地进行了构建,但是大多数情况下,我可以相当可靠地重现此问题.

There have been a couple of times where I have managed to create this type of class and then successfully build, but mostly I can reproduce this problem pretty reliably.

在这一点上,我倾向于认为该错误与Script#有关,但只是希望对此进行确认,并找到可能的解决方法.

At this point I'm inclined to think that the bug lies with Script#, but would just like to have that confirmed, and to find a possible work around if there is one.

推荐答案

以防万一有人遇到类似问题,我已经找到了引起问题的原因.

Just in case anyone is having a similar issue, I've found the cause of the problem.

使用此方法添加类或从另一个项目复制文件以在Script#中使用时,这将导致对System.dll的引用被添加到项目中.这(可以理解)使项目停止编译而没有错误.

When adding a class using this method, or copying in a file from another project for use within Script#, this causes a reference to System.dll to be added to the project. This (understandably) causes the project to stop compiling without error.

最好对此发出警告或Script#,以某种方式检测何时发生这种情况和/或为我使用添加类"或导入文件创建新模板,这很好,但这只是一个方便问题,至少现在,仅删除此引用即可使我的项目重新编译.

It would be nice to have a warning about this or for Script# to somehow detect when this situation occurs and/or create a new template for when I use 'Add class' or import a file, but it is just a convenience issue and at least now I can painlessly get my project compiling again just by removing this reference.

这篇关于脚本#和编译器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆