在VS2019 .NET 4.8中为C#项目构建安装程序失败

我在使用.NET 4.8在VS2019 Enterprise中构建的解决方案中有一个C#项目,由于这是仅供内部使用的工具,因此1)将发布的构建日志将被删除,以及2)我完全知道每台将运行此功能的计算机的硬件和.NET版本,因为它们都与我自己的完全相同。

该程序集用硬件密钥签名,因为我们使用白名单来确定哪些可以在上述笔记本电脑上运行,哪些不能在上面运行(所以我必须在本地构建),并且由于内存需求,我只在构建x64。工具。 (是的,我已经看过它运行了,是的,它使用了超过2GB的RAM,不,我对此无能为力。您只需要保证就可以了。)

因此,我说的是,我安装了microsoft制造的扩展来尝试创建MSI安装程序,因为该安装程序必须尽可能容易安装,并且不断失败。输出如下。

    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 ------
    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 ==========

(如果有一种我可以指定的语言,可以使构建日志更易于阅读,请告知我。我也可以发布日志中提到的Product.xml的内容,但是因为它有97行,除非有必要,否则我不会。)

请注意,我什至没有使用任何HTTP(严格来说是Windows Forms程序),因此我根本不知道为什么要包含system.net.http.dll。该工具仍在开发中,毫无疑问,我必须先对其进行几次重新构建,但是毫无疑问,但我只是想以一种可以拿到他们笔记本电脑上的格式来获取此东西,因为我们正在遍布全国。

那为什么不建造呢?我发现关于此的文档很少,尤其是最近的任何文档。如前几行所述,应该发生的情况是应该构建的MSI,用于安装我的exe和所有无法滚动到EXE的DLL。

(FWIW,我也尝试过在VS中使用“发布”选项,但随后它抱怨格式不正确的.manifiedt,但仍未创建我正在寻找的“一劳永逸”安装程序。)

更新

Gonzix的答案摆脱了错误,但我仍然有一些警告。这些很大吗?我可以安全地按原样部署,还是需要做其他事情?

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

我主要关心的是某些DLL冲突的情况,最终用户的计算机有些混乱,或者导致白名单工具尖叫的原因。我知道我的笔记本电脑配置了该工具,以减少尖叫(VS永远不会在其他情况下运行),所以我希望警告为零,而不仅仅是错误为零...

TL; DR 是是否仍然存在问题的警告?在什么情况下会出现问题?

heshenzhi0622 回答:在VS2019 .NET 4.8中为C#项目构建安装程序失败

如果仍然有人需要它,则xml中有一个错字,您需要在-文件的第45行中删除C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48\Product.xml字符。

,

如果使用“ Microsoft制造的”扩展名,则是指Microsoft Visual Studio安装程序扩展名,应单击安装项目并查找项目属性。默认情况下,有一个名为“ TargetPlaform”的属性指向x86。不知道是不是这样,但这为我解决了这个问题。

Property pane

,

针对项目'Microsoft .NET Framework 4.8(x86和x64)的Xml验证未通过

错误可能与this有关。

某种错字错误。 您可以使用管理员权限手动更改该文件。

本文链接:https://www.f2er.com/3165379.html

大家都在问