1

I have a C# project in a solution I built in VS2019 Enterprise, using .NET 4.8, and since this is a tool for internal use only, 1) the build log I'll be posting will be redacted, and 2) I know exactly the hardware and .NET version of every computer that'll run this, because they're all identical to my own.

The assembly is signed with a hardware key because we use whitelisting to determine what can and cannot run on said laptops, (so I HAVE to build this locally,) and I'm only building x64 because of the memory demands of the tool. (Yes, I've watched it run, yes it uses over 2GB of RAM, and no, I can't do anything about that. You'll just have to take my word on that.)

So all that said, I installed the Microsoft-made extension to try and create an MSI installer, because this needs to be as easy to install as possible, and it keeps failing. Output below.

    1>------ Rebuild All started: Project: MyCSProject, Configuration: Release x64 ------
    1>  MyCSProject -> C:\dev\Source\Repos\MySolution\MyCSProject\bin\x64\Release\MyCSProject.exe
    1>  Done Adding Additional Store
    1>  Successfully signed: C:\dev\Source\Repos\MySolution\MyCSProject\bin\x64\Release\MyCSProject.exe
    1>  
    ------ Starting pre-build validation for project 'MyCSProject Setup' ------ 
    ------ Starting pre-build validation for project 'MyCSProject Setup' ------ 
    ------ Starting pre-build validation for project 'MyCSProject Setup' ------ 
    WARNING: Unable to find dependency 'MICROSOFT.WINDOWSAPICODEPACK' (Signature='(null)' Version='1.1.0.0') of assembly 'Microsoft.WindowsAPICodePack.Shell.dll'
    WARNING: Unable to find dependency 'MICROSOFT.WINDOWSAPICODEPACK' (Signature='(null)' Version='1.1.0.0') of assembly 'Microsoft.WindowsAPICodePack.Shell.dll'
    WARNING: Unable to find dependency 'MICROSOFT.WINDOWSAPICODEPACK' (Signature='(null)' Version='1.1.0.0') of assembly 'Microsoft.WindowsAPICodePack.Shell.dll'
    ------ Pre-build validation for project 'MyCSProject Setup' completed ------
    ------ Pre-build validation for project 'MyCSProject Setup' completed ------
    ------ Pre-build validation for project 'MyCSProject Setup' completed ------
    2>------ Rebuild All started: Project: MyCSProject Setup, Configuration: Release ------
    2>------ Rebuild All started: Project: MyCSProject Setup, Configuration: Release ------
    2>------ Rebuild All started: Project: MyCSProject Setup, Configuration: Release ------
    Building file 'C:\dev\Source\Repos\MySolution\MyCSProject Setup\Release\MyCSProject Setup.msi'...
    Building file 'C:\dev\Source\Repos\MySolution\MyCSProject Setup\Release\MyCSProject Setup.msi'...
    Building file 'C:\dev\Source\Repos\MySolution\MyCSProject Setup\Release\MyCSProject Setup.msi'...
    WARNING: Xml validation did not pass for item 'Microsoft .NET Framework 4.8 (x86 and x64)' located at 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml'.
    WARNING: Xml validation did not pass for item 'Microsoft .NET Framework 4.8 (x86 and x64)' located at 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml'.
    WARNING: Xml validation did not pass for item 'Microsoft .NET Framework 4.8 (x86 and x64)' located at 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml'.
    WARNING: Xml Validation error in file 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml': The element 'InstallConditions' in namespace 'http://schemas.microsoft.com/developer/2004/01/bootstrapper' cannot contain text. List of possible elements expected: 'http://schemas.microsoft.com/developer/2004/01/bootstrapper:BypassIf http://schemas.microsoft.com/developer/2004/01/bootstrapper:FailIf'.
    WARNING: Xml Validation error in file 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml': The element 'InstallConditions' in namespace 'http://schemas.microsoft.com/developer/2004/01/bootstrapper' cannot contain text. List of possible elements expected: 'http://schemas.microsoft.com/developer/2004/01/bootstrapper:BypassIf http://schemas.microsoft.com/developer/2004/01/bootstrapper:FailIf'.
    WARNING: Xml Validation error in file 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml': The element 'InstallConditions' in namespace 'http://schemas.microsoft.com/developer/2004/01/bootstrapper' cannot contain text. List of possible elements expected: 'http://schemas.microsoft.com/developer/2004/01/bootstrapper:BypassIf http://schemas.microsoft.com/developer/2004/01/bootstrapper:FailIf'.
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    ERROR: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'AMD64' is not compatible with the project's target platform 'x86'
    ERROR: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'AMD64' is not compatible with the project's target platform 'x86'
    ERROR: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'AMD64' is not compatible with the project's target platform 'x86'
    WARNING: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'x64' is not compatible with the project's target platform 'x86'
    WARNING: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'x64' is not compatible with the project's target platform 'x86'
    WARNING: File 'MyCSProject.exe' of project output 'Primary output from MyCSProject (Active)' targeting 'x64' is not compatible with the project's target platform 'x86'
    Build process cancelled
    ========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

(If there's a language that I can specify that'll make the build log easier to read, by all means, let me know. I can also post the content of the Product.xml that the log mentions, but since it's 97 lines long, I won't unless necessary.)

Side note, I'm not even using anything HTTP, (this is strictly a Windows Forms program,) so I have no idea why system.net.http.dll is being included at all. The tool is still in development, so I'll have to re-build several times before it's done, no doubt, but I'm just trying to get this thing in a format that I can get to their laptops, because we're flung all over the country.

So why isn't it building? I'm finding there's little documentation on this, especially anything recent. What's supposed to happen, as the first few lines indicate, is an MSI should be built that installs my exe and any DLLs that can't be rolled into the EXE.

(FWIW, I've also tried using the Publish option in VS, but then it complains about a malformed .manifiest, and it still doesn't create that "one and done" installer that I'm looking for.)

Update

Gonzix's answer got rid of the errors, but I still have some Warnings. Are these a big deal? Can I safely deploy as-is, or do I need to do something else?

    WARNING: Unable to find dependency 'MICROSOFT.WINDOWSAPICODEPACK' (Signature='(null)' Version='1.1.0.0') of assembly 'Microsoft.WindowsAPICodePack.Shell.dll'
    ------ Pre-build validation for project 'MyCSProject Setup' completed ------
    2>------ Rebuild All started: Project: MyCSProject Setup, Configuration: Release ------
    Building file 'C:\dev\Source\Repos\MySolution\MyCSProject Setup\Release\MyCSProject Setup.msi'...
    WARNING: Xml validation did not pass for item 'Microsoft .NET Framework 4.8 (x86 and x64)' located at 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml'.
    WARNING: Xml Validation error in file 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\product.xml': The element 'InstallConditions' in namespace 'http://schemas.microsoft.com/developer/2004/01/bootstrapper' cannot contain text. List of possible elements expected: 'http://schemas.microsoft.com/developer/2004/01/bootstrapper:BypassIf http://schemas.microsoft.com/developer/2004/01/bootstrapper:FailIf'.
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.net.http.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')
    WARNING: Two or more objects have the same target location ('[targetdir]\system.runtime.dll')

My main concern is some dueling-DLL situation where the end user's computer somehow gets confused, or something that causes the tool that does the whitelisting to scream. I know my laptop's configured for that tool to scream less, (VS would never run otherwise,) so I'd like there to be zero warnings, not just zero errors...

TL;DR are the warnings that I'm still getting a problem or not? Under what circumstances COULD they be a problem?

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Janet
  • 343
  • 6
  • 19
  • Maybe you can try to add all project output first, then remove the added dependencies in the dependency node manually. – 大陸北方網友 Nov 05 '19 at 01:51
  • 2
    Don't have time to answer properly, but those files are part of the .NET framework and should not be redistributed. Add the files you need manually as suggested and remove any "auto-magic" that shoots from the hip and adds unnecessary stuff. Also make sure to build the x64 bit version since that is what you need (memory). Maybe consider using a better [MSI creation tool](https://stackoverflow.com/a/50229840/129130). And throwing in [WiX quick start](https://stackoverflow.com/questions/25004226/msi-vs-nuget-packages-which-are-is-better-for-continuous-delivery/25005864#25005864). – Stein Åsmul Nov 05 '19 at 03:01
  • @SteinÅsmul I looked into those tools, but I'd have to go through a long process to request permission to run them on my laptop :( – Janet Nov 05 '19 at 13:49
  • "I'm finding there's little documentation on this, especially anything recent." It seems that eventually MS abandons every API it creates. Are you building a lot of these internal applications? If so, you might consider doing your own installer. Not trivial, but may be worthwhile to get off the MSI treadmill. I did it for a commercial application, so it's possible. – Jim Foye Nov 08 '19 at 16:11
  • You really should consider migrating to another technology, https://blog.lextudio.com/the-horrible-facts-on-visual-studio-setup-projects-45e66fe86d8d – Lex Li Dec 28 '19 at 02:10
  • @JimFoye abandoning old technologies is done by all major IT companies, so your words are unfair. MSI is still heavily used (even by Microsoft itself) and Microsoft created WiX toolkit since 2003 for that. So it is just the legacy Visual Studio Setup project that bites users badly, especially when those users never try to take a further look around. – Lex Li Dec 28 '19 at 02:13

3 Answers3

24

In case anyone still need it, there is a typo in the xml, you need to remove - char at line 45 of C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\Product.xml file.

SIRS
  • 624
  • 6
  • 20
1

If by "Microsoft-made" extension you mean the Microsoft Visual Studio installer extension you should click on the install project and look for the project properties. There is a property called "TargetPlaform" that points to x86 by default. Don't know if this is the case, but that fixed the problem for me.

Property pane

Gonzix
  • 1,136
  • 5
  • 8
  • Great! That gets me 85% there. Edited the original question for the errors I'm still getting. – Janet Nov 04 '19 at 19:06
1

Xml validation did not pass for item 'Microsoft .NET Framework 4.8 (x86 and x64)

error may be related to this.

Some kind of typo error. You can change that file manually with admin privileges.