Disabling the *.vshost.exe and miscellaneous files from being created on build

后端 未结 2 606
名媛妹妹
名媛妹妹 2020-12-03 00:45

I found the following information about the Microsoft Visual Studio \"extra\" files:

What is the purpose of the vshost.exe file?

My question is, is there a w

相关标签:
2条回答
  • 2020-12-03 01:35

    Switch to the Release configuration. Then Project + Properties, Debug tab, untick the "Enable the Visual Studio hosting process" option. Build + Clean, you can delete anything that's left and it won't come back. That this option is turned on by default for the Release build is, arguably, a bit of a flaw but defensible.

    The hosting process is a custom hosted version of the CLR. Exactly what it does is not well documented but it is related to configuring the security settings of the primary AppDomain. I've never heard anybody complain about battling CAS problems without it, but then it is unusual to turn it off and your app almost always runs in full trust when debugging from the IDE. It would matter if you build to a network share on early versions of .NET. The only thing that's obvious from disabling it is that anything you write with Console.Write in a gui style app will no longer appear in the Output window. It has nothing to do with speed as claimed in the highly upvoted answer in the link, the core framework DLLs are already resident in RAM since VS and MSBuild uses them.

    Best thing to do is just not worry about it too much. A Setup and Deployment project will ignore it.

    0 讨论(0)
  • 2020-12-03 01:41

    Regarding vshost files, at least in VS2010:

    • They are not generated on build, but on selection of build configuration (it will be generated in release when we select release for the first time) and on setting "Enable the Visual Studio hosting process" to true. (As configuration debug and this option set to true are defaults, vshost.exe will be created in bin/debug on opening VS with target project by default.)
    • They are not cleaned on rebuilding or cleaning the project, but only manually when "Enable the Visual Studio hosting process" is false if VS with that project is open. (And it won't be generated anymore when opening this project.)

    If this flag option is true and VS with target project is opened, this file cannot be deleted as being used. Once when it is unchecked, vshost.exe can be immediately deleted.

    Summary: Generating and removing these files is not related to build process.

    Also, I may add that option "Enable the Visual Studio hosting process" in referenced projects which are class libraries is not considered. This option is only considered for target project which generates executable file.

    0 讨论(0)
提交回复
热议问题