12

I am using clickonce for a windows forms application. I have to deploy some resource assemblies. These assemblies are in a folder in my project (not as a reference). They are marked BuildAction = content and CopyToOutputDir = Copy If Newer. With this configuration I'm getting the warning MSB3178: Assembly '' is incorrectly specified as a file.

When I set the BuildAction to none, the warnings disappear, but the assemblies that must deploy not appear in ClickOnce Application Files.

I would like to add these assemblies (there are many) in the publication of clickonce without this warning and without adding these dlls as references in the project. I researched a lot and could not find a solution to disable the warning.

Edit:

The warning appears only when I set "Enable Clickonce Security Settings" = "True" in "Project / Properties / Security Tab"

SAMPLE PROJECT:

Click to download the sample project

Just build and check the Warnings.

Vinicius Gonçalves
  • 2,514
  • 1
  • 29
  • 54
  • Instead of setting the `BuildAction` to `content`, try leaving it at `none` and change `CopyToOutputDir` to `CopyAlways`. – Thorsten Dittmar Aug 17 '16 at 14:25
  • Hi @ThorstenDittmar! I did it, however the assembly does not appear in Click Once Application Files (Project/Properties/Publish Tab) :/ – Vinicius Gonçalves Aug 17 '16 at 16:18
  • I edited my question, please check. – Vinicius Gonçalves Aug 17 '16 at 16:24
  • Is there a special reason you dont want it to set as reference? – lokusking Aug 20 '16 at 17:38
  • Hi @lokusing! Yes, there are hundreds of resources dlls – Vinicius Gonçalves Aug 21 '16 at 10:33
  • I'm having problems downloading your sample project, on onedrive its say "the file is not shared", it maybe because of a firewall my end. Can you share file access and make sure there is no DLLs or EXEs in the bin folder. – Jeremy Thompson Aug 24 '16 at 01:22
  • Hi @JeremyThompson, please try again, I cleaned the solution – Vinicius Gonçalves Aug 24 '16 at 16:26
  • You have not indicated how these dll's are used, but if you change the extension from "dll" to something else, you will not get that error. You can still do an `Assembly.LoadFile` with the changed extension, assuing that is how you are consuming the dll. – TnTinMn Aug 24 '16 at 18:08
  • Hi @TnTinMn, I'm using a third-party component that needs the files have the .dll extension – Vinicius Gonçalves Aug 24 '16 at 19:03
  • `" I'm using a third-party component"` - So effectively, these Dll's are a prerequisite for your application. I have never done this and the procedure looks a bit involved, but take a look at [Creating Bootstrapper Packages](https://msdn.microsoft.com/en-us/library/ms165429.aspx) to create an installer for these files and add it as a PreRequisite in the ClickOnce setup tab. I doubt this is the quick solution you where seeking. :) – TnTinMn Aug 24 '16 at 19:39
  • Thank you for proposing the alternative solution! I am puzzled by this seemingly insoluble warning, can not disable or solve it, you know any way to do this? – Vinicius Gonçalves Aug 25 '16 at 00:20
  • 1
    As Jeremy has already stated this cannot be done. If the real problem which you are facing is to not able to locate other errors/warnings , you can use third party tool which will enable you to export your results from error list to excel or pdf and you can filter results easily . One Such is https://visualstudiogallery.msdn.microsoft.com/6eefa957-1a7f-48d3-95a9-60dbaa2485a5 - See if it works for u. – FakeisMe Aug 26 '16 at 13:14
  • Tks FakeisMe! I think this is a very common task, really very strange can not suppress this warning. – Vinicius Gonçalves Aug 26 '16 at 16:21

1 Answers1

9

Suppressing MSBuild warnings is still not possible.

Warnings with MSB prefix are thrown by MSBuild. Currently, we can't suppress MSBuild warnings.

Ref: https://social.msdn.microsoft.com/Forums/vstudio/en-US/96b3ea2e-92ed-4483-bbfe-a4dda3231eb9/suppress-msb4126?forum=tfsbuild

There are a few you can suppress in the PropertyGroup of your .csproj file, for example:

<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>

However none exist for the incorrectly specified as a file warning.


Since you cant fix the root cause of the MSB3178 due to the file extension of a 3rd party DLL, you have justification to ignore that particular warning.

Related SO threads here and here and on MSDN. The exact same question on MSDN.

Community
  • 1
  • 1
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • Hello Jeremy Thompson, thank you for the answer. Before publishing the issue here I researched these links you posted. I really thought it would be possible to somehow suppress these warnings. The real problem is that I have 140 warnings about the same problem. When an important warning appears he is among hundreds of others. Can not suppress this warning is too inconvenient. – Vinicius Gonçalves Aug 25 '16 at 12:01
  • I know, it really is unfortunate and I wish my research yielded a solution but I too came to the same understanding. You can't even do this with introspection! One more thought on it is a VS AddIn as per my 2nd last "bounty answer". Though even then this request requires a black magic answer... Sorry to repeat your own research here – Jeremy Thompson Aug 25 '16 at 12:09
  • I am very grateful for your attention @Jeremy Thompson. There is a very common scenario that is impossible not have been foreseen. Imagine that I am using an unmanaged assembly from my code (dllimport) and must publish it. How do without this warning? Curious... – Vinicius Gonçalves Aug 25 '16 at 18:12