Tyl*_*ler 5 c# resharper intellisense code-generation visual-studio-2010
背景:
我们在.NET C#解决方案中使用第三方工具.此工具具有自己的语法并与Visual Studio集成.当我们使用这个工具时,我们在Visual Studio中编写它的标记,然后当我们构建解决方案时,自定义工具运行并根据我们编写的标记生成.cs文件.
生成的源文件包含一个版本号,当我们将这些版本控制到版本控制时会产生问题(无休止的冲突).我们的理解是,最好不要检查生成的源文件.
因此我们从SVN中排除了生成的.cs文件,然后我们遇到的下一个问题是Visual Studio解决方案引用了这些文件,因此当TeamCity(我们的持续构建/集成软件)去构建解决方案时,它会立即失败因为它找不到这些文件.
然后我们从解决方案中删除了这些并将它们从SVN中排除,这解决了原始问题,我们不再检查生成的代码,并且它在TeamCity中构建良好(因为文件是在每次构建时重新生成的).
我们现在遇到了一个新问题 - 由于生成的文件不再包含在解决方案中,因此无法找到生成的类,因此智能感知和代码检查失败.解决方案构建得很好(再次在构建期间重新生成代码).
题
有没有办法告诉ReSharper在代码检查中包含生成的.cs文件?这些文件在解决方案外部,但它们位于obj目录中.
干杯,
泰勒
我们遇到了类似的问题,找不到好的解决方案,所以我编写了一个 ReSharper 扩展来包含外部代码:
https://resharper-plugins.jetbrains.com/packages/ReSharper.ExternalCode
正如我的评论中提到的,一种解决方法是将生成的文件保留在解决方案中(但不在源代码管理中),同时添加预构建步骤来创建空的 .cs 文件(如果真正生成的文件不存在),以便该文件在构建期间始终可用。
在我的项目中,我使用以下 MSBuild 目标通过Touch任务生成空文件。您可能需要进行一些修改 - 就我而言,目标文件实际上是在项目中定义的,而不是在解决方案级别;文件的构建操作设置为“无”,这对于理解这些目标的工作原理非常重要。
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!--
Creates empty 'dummy' files for any files that are specified but do not exist.
To be processed, the following must be true:
1. The file is included in an ItemGroup called CanCreateDummy, e.g.
<ItemGroup>
<CanCreateDummy Include="SomeFile.cs" />
</ItemGroup>
If you want to specify a CanCreateDummy file in the .csproj file, you would
modify the above slightly as follows to prevent it appearing twice:
<ItemGroup>
<CanCreateDummy Include="SomeFile.cs">
<Visible>false</Visible>
</CanCreateDummy>
</ItemGroup>
2. The file is included in the ItemGroup called None. This is normally performed
by adding the file to the project in the usual way through Visual Studio, and
then setting the file's Build Action property to None.
-->
<Target
Name="CreateDummyFiles"
AfterTargets="BeforeBuild"
>
<!--
This voodoo creates the intersection of 2 lists - @(CanCreateDummy) and @(None)
(this latter item is defined in the project file). We want to create a filtered
list of all items that are in both these lists, which is called _ProjectDummyFiles.
See http://blogs.msdn.com/b/msbuild/archive/2006/05/30/610494.aspx for how the
Condition voodoo works.
-->
<CreateItem Include="@(CanCreateDummy)" Condition="'%(Identity)' != '' and '@(None)' != ''" >
<Output TaskParameter="Include" ItemName="_ProjectDummyFiles"/>
</CreateItem>
<Message
Text="Creating dummy settings file @(_ProjectDummyFiles)"
Condition=" !Exists('%(_ProjectDummyFiles.FullPath)')"
/>
<Touch
AlwaysCreate="true"
Files="@(_ProjectDummyFiles)"
Condition=" !Exists('%(_ProjectDummyFiles.FullPath)')"
/>
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
富有的