15

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 starts 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.

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
  • 1
    Gentlemen, dear downvoters: even if you think my motivations are wrong and I shouldn't remove the license.licx, let's discuss it, please consider that a conclusion of this topic can be beneficial for others who are in the same shoe as me. Thank you for your understanding! – Csaba Toth Aug 05 '13 at 21:34
  • I removed the rage face since some people might think it's not funny. – Csaba Toth Aug 05 '13 at 21:35
  • On the flip side; as it's part of the inputs to the build, why wouldn't you want it to be managed as part of your source control? I'm sure you'd have no qualms with including other resources in source control? – Rowland Shaw Aug 06 '13 at 06:46
  • http://community.devexpress.com/blogs/ctodx/archive/2009/03/06/licenses-licx-file-woes.aspx "Visual Studio has a propensity of touching this file if you open the solution. This plays havoc with licensing, especially if you happen open the solution on a non-licensed machine and you are using source control. Suddenly your build machine will throw off these "cannot transform" messages" – Csaba Toth Aug 06 '13 at 18:22
  • Never had any problems, and my build server builds a variety of projects, most involving licences; it's more a case of correctly configuring the build environment... – Rowland Shaw Aug 06 '13 at 18:29
  • We have the rule no to have the file since VS 2005/2008 times. Maybe it doesn't cause problems at VS 2012 ages any more? We certainly don't have time to discover that. And why we would start to include it now, if we don't have any problem without it! Then why we would need it? (besides having this annoyance this Question is about). Why would it be so important for us? – Csaba Toth Aug 06 '13 at 20:01
  • Even though the suite is installed and licensed on the server, these files actually break our TFS (Azure DevOps) builds. Every. Single. Time. – reckface Oct 10 '18 at 08:28
  • @reckface It's a PITA! – Csaba Toth Oct 10 '18 at 18:48
  • Still an issue in VS 2022! Embarrassing. :E – Andreas Jan 18 '23 at 11:24

5 Answers5

12

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.

captray
  • 3,618
  • 1
  • 18
  • 15
  • I really appreciate your answer. Most likely there's no switch in Visual Studio to turn of the licx creation, so your answer seems to be a good solution. Actually we have a unit test which fails if such rogue licx created, preventing accidental commits of it. Do you happen to have a sample post build script? What do you use to manipulate the solution in the post build script? PowerShell + EnvDte or something else? [StudioShell](https://studioshell.codeplex.com/)? – Csaba Toth Aug 06 '13 at 18:16
  • 1
    You can go the Post Build Event and paste something like this... del "$(SolutionDir)Project\folder\license.licx" and that should take care of it. – captray Aug 07 '13 at 02:04
  • 4
    Deleting licenses.licx would cause "Could not find file ...\licenses.licx" error. Instead we could add this pre-build event to create (or overwrite) an empty licenses.licx: copy /y NUL $(ProjectDir)Properties\licenses.licx > NUL – Chris Xue Mar 30 '16 at 09:57
  • COPY /y NUL "$(ProjectDir)Properties\licenses.licx" Put double quotes incase your path has spaces – Mnyikka Jan 09 '23 at 19:16
3

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>

Andrew Stakhov
  • 1,105
  • 8
  • 26
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".

M-Peror
  • 712
  • 8
  • 16
1

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).

C. Augusto Proiete
  • 24,684
  • 2
  • 63
  • 91
-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.

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • 1
    Why would I need license.licx? If I don't double click on the file accidentally it's not even created. Can it cause problems in a development team? For example John Doe double clicks on something else, then he generates one with different content? I guess there are some cryptography under the hood. – Csaba Toth Aug 05 '13 at 21:30
  • (John Doe works on the same software as me. And I don't want the licx in the source control. Maybe when we manufacture the release we'll need it. Our product is an end-user product, not a third party library. I hope we don't breach any license with our third party vendors.) – Csaba Toth Aug 05 '13 at 21:36
  • 1
    So the short question is: why is it so important for me that I have to have it? I want explanations. – Csaba Toth Aug 05 '13 at 21:52
  • http://stackoverflow.com/questions/51363/how-does-the-licenses-licx-based-net-component-licensing-model-work not advised to keep it in source control. We work in more teams on the same source. Many people. – Csaba Toth Aug 05 '13 at 21:57
  • The advice on the highest voted answer on that other question, and also on Denis' is that it should be included, such that the licence compiler knows to go looking for the licence to include in the final project. Have you tried removing all the licences.licx, building (or even using a continuous integration build), and running the result that doesn't have the developer version of the controls installed? I would expect the result to misbehave in some manner... – Rowland Shaw Aug 06 '13 at 06:40
  • Would love to know why this attracts so many anonymous downvotes (vs. people commenting) – Rowland Shaw Sep 15 '15 at 16:22
  • I assume the anonymous downvotes are because there's still no explanation of why it is so important. Without the accidental double click it is not there and things work (in the development environment). It's obviously important in case of staging builds for testing or release builds, but we are talking about everyday development. – Csaba Toth Oct 10 '18 at 18:47
  • You cannot say that something is important without telling why. – Anders Lindén Feb 27 '19 at 08:47