How can I prevent Visual Studio from creating license.licx

▼魔方 西西 提交于 2019-12-06 20:16:13

问题


We use 3rd party controls in our project. Almost every time when I double click on a file which has a design view too, Visual Studio tries to bring up the designer with heroic effort, and after some unresponsiveness it delivers (gives birth to) a license.licx file into our solution. That unnecessarily disturbs the source control: the file addition modifies the csproj too, and also the original code file plus the designer.cs gets checked out (although they don't have any modification in them).

  1. I only want to see code (right click, View Code), I don't want to see the designer view.
  2. Each time I need to undo the unnecessary changes and that takes time (our solution is gargantuous), while Visual Studio is unresponsive again, since it reloads the whole shebang since the csproj changed.
  3. When I double click, I immediately realize what I did, but it's already too late at that time, the clockwork start to grind.

If anyone knows how to disable the addition of that licx, please let me know. FYI: relevant third party libraries are DevExpress WinForms and IdeaBlade DevForce Classic (which has some integration with DevExpress). I use VS 2012. And our product is an end-user product, and not a third party library.

Clarification: we are talking about a development environment. See How does the Licenses.licx based .Net component licensing model work? -- it's not advised to keep it in source control. I don't want to debate about that. Let's focus on how to prevent Visual Studio to try to create it all the time.


回答1:


You can create a post build event that removes the .licx file for you. We've dealt with this annoyance on our team, and aside from manually excluding or deleting it, the post build event is your best bet. Every time you open a Windows Form, the file will be added again if that form is referencing or using any of the 3rd party .dlls.

You can specify the pre and post build events via console or by right clicking on the project and selecting Properties -> Build Events. Hope this helps.




回答2:


If anyone is looking for solution for this problem because they are using precompiled licenses via Lc.exe tool and want to prevent licenses.licx from conflicting on build server, edit your csproj file, and change line that looks like this:

<EmbeddedResource Include="Properties\licenses.licx" />

into this:

<ItemGroup Condition=" '$(Configuration)' != 'Release' " > <EmbeddedResource Include="Properties\licenses.licx" /> </ItemGroup>




回答3:


For your point #1, you could prevent double-clicking from opening the designer but instead open the code editor by default.

You can do this by:

  • right-clicking on a .cs file that has a form
  • select "Open with..."
  • select "CSharp Editor" (or VB)
  • click "Set as Default"
  • and OK

If you want to change it back later, follow same procedure but pick "CSharp Form Editor".




回答4:


If you use the EmptyLicensesLicx NuGet package, it will create an empty Licenses.licx file in your project on every build (which is all you really need).




回答5:


That license.licx is important. You really do want it in your projects that use components licenced from third parties. If you don't use third party components, the licences.licx file will not be added.



来源:https://stackoverflow.com/questions/18067795/how-can-i-prevent-visual-studio-from-creating-license-licx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!