visual-studio VS 2008 专业版,智能设备 .NET C# 项目 - 构建缓慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3933749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:36:55  来源:igfitidea点击:

VS 2008 Professional, Smart Device .NET C# project - slow build

c#.netvisual-studiowindows-mobilecompilation

提问by cubesoft

I have VS 2008 Professional and a Smart Device .NET C# project. I have ~100 cs files in total. The build takes a very long time, I have to wait for linker approx. 1min (60s) every time I compile the project. I have Core i3, 4GB RAM, 7200rpm disk.

我有 VS 2008 Professional 和智能设备 .NET C# 项目。我总共有大约 100 个 cs 文件。构建需要很长时间,我必须等待链接器大约。每次编译项目时需要 1 分钟(60 秒)。我有 Core i3、4GB RAM、7200rpm 磁盘。

What causes this and how can I optimize the build? Any Visual Studio options?

是什么导致了这种情况,我该如何优化构建?任何 Visual Studio 选项?

回答by Wolfwyrd

If you follow the advise from Hans Passant's comment and set MSBuild to diagnostic output it will give a clearer picture of just what is taking the time. If you find that your build is hanging on the Licensing Compiler (LC.exe) then this could be due to it trying to call a server and timing out. You can resolve this by altering your machine.config -

如果您遵循 Hans Passant 评论中的建议并将 MSBuild 设置为诊断输出,它将更清楚地了解正在花费时间的内容。如果您发现您的构建挂在许可编译器 (LC.exe) 上,那么这可能是因为它试图调用服务器并超时。您可以通过更改 machine.config 来解决此问题 -

edit c:\windows\microsoft.net\framework\v2.0.50727\config\machine.config, and add the following key:

编辑 c:\windows\microsoft.net\framework\v2.0.50727\config\machine.config,并添加以下项:

  <configuration>
    <runtime>
      <generatePublisherEvidence enabled="false"/>

EDIT://

编辑://

Based on the comment below I did a little digging. The platform verification task has a known issue where it runs very slowly in VS2008. More detail on it can be found here:

根据下面的评论,我做了一些挖掘。平台验证任务有一个已知问题,它在 VS2008 中运行非常缓慢。可以在此处找到有关它的更多详细信息:

http://blogs.msdn.com/b/vsdteam/archive/2006/09/15/756400.aspx

http://blogs.msdn.com/b/vsdteam/archive/2006/09/15/756400.aspx

One way around this is to disable the task itself in your build. To do this

解决此问题的一种方法是在构建中禁用任务本身。去做这个

1) Open the file:

1)打开文件:

%windir%\Microsoft.NET\Framework\v2.0.50727\Microsoft.CompactFramework.Common.Targets

for editing.

用于编辑。

2) Go to the line which reads:

2)转到以下行:

Name="PlatformVerificationTask">

and change it to:

并将其更改为:

Name="PlatformVerificationTask" Condition="'$(SkipPlatformVerification)' != 'true'">

3) Add the SkipPlatformVerification environment variable to the system and set it to "true" (To re-enable Platform Verification set the environment variable to "false"). If you need help on setting up an environment variable read http://vlaurie.com/computers2/Articles/environment.htm. If you don't want to add an environment variable you can swap the condition for something that is always false (i.e. Condition="'true' == 'false'")

3) 将 SkipPlatformVerification 环境变量添加到系统并将其设置为“true”(要重新启用平台验证,请将环境变量设置为“false”)。如果您需要有关设置环境变量的帮助,请阅读http://vlaurie.com/computers2/Articles/environment.htm。如果您不想添加环境变量,则可以将条件交换为始终为假的内容(即 Condition="'true' == 'false'")

回答by HelloSam

Just re-define an target in your .csproj file like this. Then it will works across the machine, Or of course you could copy the whole block of code with the conditional line added. Either way, you need not to modify the system file.

只需像这样在 .csproj 文件中重新定义目标。然后它将在整个机器上工作,或者当然您可以复制整个代码块并添加条件行。无论哪种方式,您都不需要修改系统文件。

<Target Name="PlatformVerificationTask"></Target>

回答by Tahir FEYZIOGLU

For windows 10 and framework 3.5,

对于 Windows 10 和框架 3.5

in C:\Windows\Microsoft.NET\Framework\v3.5 folder, find Microsoft.CompactFramework.common.targets file.

在 C:\Windows\Microsoft.NET\Framework\v3.5 文件夹中,找到 Microsoft.CompactFramework.common.targets 文件。

In this section

在这个部分

<Target
    Name="PlatformVerificationTask">
    <PlatformVerificationTask
        PlatformFamilyName="$(PlatformFamilyName)"
        PlatformID="$(PlatformID)"
        SourceAssembly="@(IntermediateAssembly)"
        ReferencePath="@(ReferencePath)"
        TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
        PlatformVersion="$(TargetFrameworkVersion)"/>
</Target>

change this, (add Condition="'$(DoPlatformVerificationTask)'=='true'" line)

改变这个,(添加 Condition="'$(DoPlatformVerificationTask)'=='true'" 行)

<Target
    Name="PlatformVerificationTask">
    <PlatformVerificationTask
        Condition="'$(DoPlatformVerificationTask)'=='true'" <!-- Added -->
        PlatformFamilyName="$(PlatformFamilyName)"
        PlatformID="$(PlatformID)"
        SourceAssembly="@(IntermediateAssembly)"
        ReferencePath="@(ReferencePath)"
        TreatWarningsAsErrors="$(TreatWarningsAsErrors)"
        PlatformVersion="$(TargetFrameworkVersion)"/>
</Target>