从VS Setup MSI升级到被视为卸载的Wix MSI

时间:2017-06-06 17:32:34

标签: installation wix windows-installer setup-project

情境:

到目前为止,我们已经使用了VS 2010安装项目。将新版本迁移到Wix。

问题:

// // CameraViewController.swift // MatchFriend // // Created by Tarek Ezzat Abdallah on 10/1/16. // Copyright © 2016 Tarek. All rights reserved. // import UIKit import AVFoundation class CameraViewController: UIViewController{ var captureSession: AVCaptureSession? var previewLayer : AVCaptureVideoPreviewLayer? var stillImageOutput: AVCaptureStillImageOutput? var imageToSend: UIImage! // If we find a device we'll store it here for later use var captureDevice : AVCaptureDevice? @IBOutlet weak var cameraView: UIView! var captureButton: UIButton! var flipCam:UIButton! var camPos:String = "back" func capture(_ sender: AnyObject) { if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo) { stillImageOutput?.captureStillImageAsynchronously(from: videoConnection) { (imageDataSampleBuffer, error) -> Void in let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageDataSampleBuffer) let dataProvider = CGDataProvider(data: imageData as! CFData) let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.defaultIntent ) let image = UIImage(cgImage: cgImageRef!, scale: 1.0, orientation: UIImageOrientation.right) } } } override func viewDidLoad() { super.viewDidLoad() cameraView.backgroundColor = .clear self.view.backgroundColor = .clear captureButton = UIButton(frame: CGRect(x: 160, y: 580, width: 80, height: 80)) captureButton.addTarget(self, action: #selector(CameraViewController.capture(_:)), for: UIControlEvents.touchUpInside) flipCam = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 40)) flipCam.addTarget(self, action: #selector(CameraViewController.flip), for: UIControlEvents.touchUpInside) self.view.addSubview(captureButton) self.view.addSubview(flipCam) captureButton.backgroundColor = UIColor.red NotificationCenter.default.addObserver(self, selector: #selector(CameraViewController.rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) // let backCamera = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo) camStart(camPos) setViews() } func camStart(_ position: String) { captureSession = AVCaptureSession() captureSession?.sessionPreset = AVCaptureSessionPresetHigh let videoDevices = AVCaptureDevice.devices(withMediaType: AVMediaTypeVideo) var capDevice:AVCaptureDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo) if(position == "back") { for device in videoDevices! { let device = device as! AVCaptureDevice if device.position == AVCaptureDevicePosition.back { capDevice = device break } } } else{ for device in videoDevices! { let device = device as! AVCaptureDevice if device.position == AVCaptureDevicePosition.front { capDevice = device break } } } // var error : NSError? let input = try? AVCaptureDeviceInput(device: capDevice) if (captureSession?.canAddInput(input) != nil){ captureSession?.addInput(input) stillImageOutput = AVCaptureStillImageOutput() stillImageOutput?.outputSettings = [AVVideoCodecKey : AVVideoCodecJPEG] if (captureSession?.canAddOutput(stillImageOutput) != nil){ captureSession?.addOutput(stillImageOutput) previewLayer = AVCaptureVideoPreviewLayer(session: captureSession) previewLayer?.videoGravity = AVLayerVideoGravityResizeAspect previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.portrait previewLayer!.frame = self.view.layer.frame previewLayer!.videoGravity = AVLayerVideoGravityResizeAspectFill cameraView.layer.addSublayer(previewLayer!) captureSession?.startRunning() } } } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() captureButton.frame = CGRect(x: self.view.frame.width/2 - 40, y: self.view.frame.height - 70 - 40, width: 80, height: 80) flipCam.frame = CGRect(x: self.view.frame.width/6 - 40, y: self.view.frame.height - 60 - 40, width: 80, height: 80) //add the image to flip camera //flipCam.setImage(UIImage(named: "switchCam"), for: UIControlState.normal) flipCam.setTitle("flip", for: .normal) if previewLayer != nil{ previewLayer!.frame = self.view.frame } } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(true) setViews() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func setViews() { captureButton.layer.cornerRadius = captureButton.layer.bounds.width/2 captureButton.layer.borderWidth = 1 } func configureDevice() { let error: NSErrorPointer? = nil if let device = captureDevice { do { try captureDevice!.lockForConfiguration() } catch let error1 as NSError { error??.pointee = error1 } device.focusMode = .locked device.unlockForConfiguration() } } func flip() { captureSession?.stopRunning() if camPos == "back" { camPos = "front" } else{ camPos = "back" } camStart(camPos) } func rotated() { if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) { if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft{ previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeRight } else { previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.landscapeLeft } } if UIDeviceOrientationIsPortrait(UIDevice.current.orientation) { if UIDevice.current.orientation == UIDeviceOrientation.portrait{ previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.portrait } else { previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.portraitUpsideDown } } } } 将升级视为卸载+全新安装,而不仅仅是升级。

详细信息:

  • 我在新的WIX设置中使用了相同的Msiexec Guid
  • 我已根据需要添加了UpgradeCode标记
  • 我还尝试使用MajorUpgradeUpgrade代替UpgradeVersion
  • 版本号已更新
  • 我重组了WXS,看看是不是问题而且

注意 - 系统正确识别两个产品,并在设置过程中自动删除旧产品。

问题是,旧产品是作为卸载而不是升级运行的。 我有一个自定义操作集,可以在卸载期间运行,这将删除用户数据。现在问题是,由于某种原因,在升级过程中会触发此自定义操作。

如果MajorUpgrade2010 to 2010只有Wix to Wix <才会发生此问题。 / p>

方案

  • 1.0(使用2010建立) - &gt; 1.1(使用2010构建) - 未触发自定义操作
  • 1.0(使用2010建立) - &gt; 1.1(使用Wix构建) - 卸载自定义操作
  • 1.1(使用Wix构建) - &gt; 1.2(使用Wix构建) - 未触发自定义操作

我在日志中注意到的唯一区别 -

对于VS 2010至2010

2010 to Wix

2010年至WIX -

Action ended: MsiUnpublishAssemblies. Return value 1.
MSI (s) (90:A4) : Skipping action: _[guid].uninstall.SetProperty (condition is false)
MSI (s) (90:A4): Skipping action: _[guid].uninstall (condition is false)
MSI (s) (90:A4) [21:54:10:299]: Doing action: UnpublishComponents
Action start 21:54:10: UnpublishComponents.

我很清楚为什么会发生这种卸载。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:2)

没有足够的信息可以确定,但这应该有所帮助:

主要升级始终会卸载正在升级的产品。这是基于新ProductCode,相同UpgradeCode和增量版本以及相同安装上下文的主要升级的定义。这意味着您的问题取决于您对“卸载自定义操作”的假设

Visual Studio“卸载”自定义操作并非真正“卸载”自定义操作。当组件(由组件id表示)被移除时调用它们。从VS 2010构建到VS 2010构建时,组件ID保持不变(内部引用计数)并且组件仍然安装。 WiX构建也是如此。当您从构建到WiX的VS 2010构建时,组件ID可能已更改,因此将删除VS 2010构建的MSI中的组件,因此将调用自定义操作。

换句话说,问题很可能是VS 2010版本中的组件ID(由于VS 2010甚至没有暗示它们的存在而无法看到)与WiX构建中的组件ID不同。