Updating deployment manifest for a ClickOnce application programmatically results in missing element, required in 4.0

后端 未结 2 1217
南旧
南旧 2021-02-06 09:52

I\'m working on automating the installer for a .NET 4.0 ClickOnce WPF application, which needs a few items to be set in the app.config file. I\'ve gone through the thor

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 10:43

    I also needed to add CompatibleFrameworks. I also tried do add the CompatibleFrameworks like this (which does not work)

    dm.CompatibleFrameworks.Add(...);
    

    My solution was to set:

    dm.TargetFrameworkMoniker = ".NETFramework,Version=v4.0";                 
    

    After this the Manifest generation was correct.

    Be careful If you set the TargetFrameworkMoniker before WriteManifest you have the twice and your application file is corrupt. Here is my solution for this:

    DeployManifest dm = ManifestReader.ReadManifest("DeployManifest", applicationFileName, false) as DeployManifest;
    dm.ResolveFiles();
    //doing stuff..
    dm.UpdateFileInfo();
    ManifestWriter.WriteManifest(dm, applicationFileName);
    dm.TargetFrameworkMoniker = ".NETFramework,Version=v4.0";
    ManifestWriter.WriteManifest(dm, applicationFileName);
    

提交回复
热议问题