190930
This commit is contained in:
21
Pilz.Updating/General.vb
Normal file
21
Pilz.Updating/General.vb
Normal file
@@ -0,0 +1,21 @@
|
||||
Imports System.IO
|
||||
|
||||
Public Module General
|
||||
|
||||
Public ReadOnly Property MyTempPath As String
|
||||
Get
|
||||
Static p As String = String.Empty
|
||||
|
||||
If String.IsNullOrEmpty(p) Then
|
||||
p = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Pilz.Updating")
|
||||
|
||||
If Not Directory.Exists(p) Then
|
||||
Directory.CreateDirectory(p)
|
||||
End If
|
||||
End If
|
||||
|
||||
Return p
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Module
|
||||
10
Pilz.Updating/Model/BuildState.vb
Normal file
10
Pilz.Updating/Model/BuildState.vb
Normal file
@@ -0,0 +1,10 @@
|
||||
Namespace Model
|
||||
|
||||
Public Enum BuildState
|
||||
Release
|
||||
ReleaseCandidate
|
||||
Beta
|
||||
Alpha
|
||||
End Enum
|
||||
|
||||
End Namespace
|
||||
8
Pilz.Updating/Model/CodeLanguage.vb
Normal file
8
Pilz.Updating/Model/CodeLanguage.vb
Normal file
@@ -0,0 +1,8 @@
|
||||
Namespace Model
|
||||
|
||||
Public Enum CodeLanguage
|
||||
VB
|
||||
CSharp
|
||||
End Enum
|
||||
|
||||
End Namespace
|
||||
13
Pilz.Updating/Model/UpdateInfo.vb
Normal file
13
Pilz.Updating/Model/UpdateInfo.vb
Normal file
@@ -0,0 +1,13 @@
|
||||
Namespace Model
|
||||
|
||||
Public Class UpdateInfo
|
||||
|
||||
Public Property Name As String
|
||||
Public Property Version As Version
|
||||
Public Property State As BuildState
|
||||
Public Property Build As UInteger
|
||||
Public Property Changelog As String
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
12
Pilz.Updating/Model/UpdatePackage.vb
Normal file
12
Pilz.Updating/Model/UpdatePackage.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Imports Pilz.Updating.Scripts
|
||||
|
||||
Namespace Model
|
||||
|
||||
Public Class UpdatePackage
|
||||
|
||||
Public ReadOnly Property Fileupdates As New List(Of String)
|
||||
Public ReadOnly Property Scripts As New List(Of Script)
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
13
Pilz.Updating/My Project/Application.Designer.vb
generated
Normal file
13
Pilz.Updating/My Project/Application.Designer.vb
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
10
Pilz.Updating/My Project/Application.myapp
Normal file
10
Pilz.Updating/My Project/Application.myapp
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>1</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
35
Pilz.Updating/My Project/AssemblyInfo.vb
Normal file
35
Pilz.Updating/My Project/AssemblyInfo.vb
Normal file
@@ -0,0 +1,35 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("Pilz.Updating")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("DRSN")>
|
||||
<Assembly: AssemblyProduct("Pilz.Updating")>
|
||||
<Assembly: AssemblyCopyright("Copyright © DRSN 2019")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("31dc53da-f8fd-459b-b1d5-b2ab13f6b910")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
62
Pilz.Updating/My Project/Resources.Designer.vb
generated
Normal file
62
Pilz.Updating/My Project/Resources.Designer.vb
generated
Normal file
@@ -0,0 +1,62 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
'class via a tool like ResGen or Visual Studio.
|
||||
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
'with the /str option, or rebuild your VS project.
|
||||
'''<summary>
|
||||
''' A strongly-typed resource class, for looking up localized strings, etc.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Returns the cached ResourceManager instance used by this class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Updating.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Overrides the current thread's CurrentUICulture property for all
|
||||
''' resource lookups using this strongly typed resource class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set(ByVal value As Global.System.Globalization.CultureInfo)
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
117
Pilz.Updating/My Project/Resources.resx
Normal file
117
Pilz.Updating/My Project/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
Pilz.Updating/My Project/Settings.Designer.vb
generated
Normal file
73
Pilz.Updating/My Project/Settings.Designer.vb
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
|
||||
|
||||
#Region "My.Settings Auto-Save Functionality"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.Pilz.Updating.My.MySettings
|
||||
Get
|
||||
Return Global.Pilz.Updating.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
7
Pilz.Updating/My Project/Settings.settings
Normal file
7
Pilz.Updating/My Project/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
17
Pilz.Updating/MyEventArgs/UpdatesFoundEventArgs.vb
Normal file
17
Pilz.Updating/MyEventArgs/UpdatesFoundEventArgs.vb
Normal file
@@ -0,0 +1,17 @@
|
||||
Imports Pilz.Updating.Model
|
||||
|
||||
Namespace MyEventArgs
|
||||
|
||||
Public Class UpdatesFoundEventArgs
|
||||
Inherits EventArgs
|
||||
|
||||
Public Property Cancel As Boolean = False
|
||||
Public Property Updates As UpdateInfo()
|
||||
|
||||
Public Sub New(updates As UpdateInfo())
|
||||
Me.Updates = updates
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
119
Pilz.Updating/Pilz.Updating.vbproj
Normal file
119
Pilz.Updating/Pilz.Updating.vbproj
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{354255D9-9536-4400-B915-FFC49C2CE93F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Pilz.Updating</RootNamespace>
|
||||
<AssemblyName>Pilz.Updating</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>Pilz.Updating.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>Pilz.Updating.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="General.vb" />
|
||||
<Compile Include="Model\UpdateInfo.vb" />
|
||||
<Compile Include="MyEventArgs\UpdatesFoundEventArgs.vb" />
|
||||
<Compile Include="Model\BuildState.vb" />
|
||||
<Compile Include="Model\CodeLanguage.vb" />
|
||||
<Compile Include="Scripts\Script.vb" />
|
||||
<Compile Include="Model\UpdatePackage.vb" />
|
||||
<Compile Include="Scripts\ScriptManager.vb" />
|
||||
<Compile Include="Scripts\ScriptPriority.vb" />
|
||||
<Compile Include="Updater.vb" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="UpdateManager" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
13
Pilz.Updating/Scripts/Script.vb
Normal file
13
Pilz.Updating/Scripts/Script.vb
Normal file
@@ -0,0 +1,13 @@
|
||||
Imports Pilz.Updating.Model
|
||||
|
||||
Namespace Scripts
|
||||
|
||||
Public Class Script
|
||||
|
||||
Public Property Priority As ScriptPriority = ScriptPriority.Before
|
||||
Public Property Language As CodeLanguage = CodeLanguage.CSharp
|
||||
Public Property Code As String
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
71
Pilz.Updating/Scripts/ScriptManager.vb
Normal file
71
Pilz.Updating/Scripts/ScriptManager.vb
Normal file
@@ -0,0 +1,71 @@
|
||||
Imports System.CodeDom.Compiler
|
||||
Imports System.Reflection
|
||||
Imports Microsoft.CSharp
|
||||
Imports Pilz.Updating.Model
|
||||
Imports Pilz.Updating.Scripts
|
||||
|
||||
Namespace Scripts
|
||||
|
||||
Public Class ScriptManager
|
||||
|
||||
Public Property ApplicationPath As String
|
||||
Public Property UpdatePackagePath As String
|
||||
|
||||
Public Sub New(applicationPath As String, updatePackagePath As String)
|
||||
Me.ApplicationPath = applicationPath
|
||||
Me.UpdatePackagePath = updatePackagePath
|
||||
End Sub
|
||||
|
||||
Private Function CompileScript(script As Script) As CompilerResults
|
||||
Dim provider As CodeDomProvider = Nothing
|
||||
Dim params As New CompilerParameters
|
||||
|
||||
'Create code provider
|
||||
Select Case script.Language
|
||||
Case CodeLanguage.CSharp
|
||||
provider = New CSharpCodeProvider
|
||||
Case CodeLanguage.VB
|
||||
provider = New VBCodeProvider
|
||||
End Select
|
||||
|
||||
'Set general options
|
||||
params.GenerateExecutable = False
|
||||
params.GenerateInMemory = True
|
||||
|
||||
'Set references
|
||||
params.ReferencedAssemblies.Add()
|
||||
|
||||
'Compile
|
||||
Dim res As CompilerResults = provider.CompileAssemblyFromSource(params, script.Code)
|
||||
|
||||
Return res
|
||||
End Function
|
||||
|
||||
Public Function CheckScriptForErrors(script As Script) As CompilerErrorCollection
|
||||
Return CompileScript(script).Errors
|
||||
End Function
|
||||
|
||||
Public Sub ExecuteScript(script As Script)
|
||||
'Compile script
|
||||
Dim res As CompilerResults = CompileScript(script)
|
||||
|
||||
If Not res.Errors.HasErrors Then
|
||||
'Get Method
|
||||
Dim mi As MethodInfo = res.CompiledAssembly.GetType("Program")?.GetMethod("Main")
|
||||
|
||||
If mi IsNot Nothing Then
|
||||
'Create params
|
||||
Dim params As New Dictionary(Of String, String) From {
|
||||
{"ApplicationPath", ApplicationPath},
|
||||
{"UpdatePackagePath", UpdatePackagePath}
|
||||
}
|
||||
|
||||
'Execute method
|
||||
mi.Invoke(Nothing, {params})
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
8
Pilz.Updating/Scripts/ScriptPriority.vb
Normal file
8
Pilz.Updating/Scripts/ScriptPriority.vb
Normal file
@@ -0,0 +1,8 @@
|
||||
Namespace Scripts
|
||||
|
||||
Public Enum ScriptPriority
|
||||
Before
|
||||
After
|
||||
End Enum
|
||||
|
||||
End Namespace
|
||||
3
Pilz.Updating/UpdateManager
Normal file
3
Pilz.Updating/UpdateManager
Normal file
@@ -0,0 +1,3 @@
|
||||
Public Class Class1
|
||||
|
||||
End Class
|
||||
86
Pilz.Updating/Updater.vb
Normal file
86
Pilz.Updating/Updater.vb
Normal file
@@ -0,0 +1,86 @@
|
||||
Imports System.IO
|
||||
Imports System.IO.Compression
|
||||
Imports System.Net
|
||||
Imports System.Reflection
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports Pilz.Updating.Model
|
||||
Imports Pilz.Updating.MyEventArgs
|
||||
|
||||
Public Class Updater
|
||||
|
||||
Public Event UpdatesFound(sender As Object, e As UpdatesFoundEventArgs)
|
||||
Public Event NoUpdatesFound(sender As Object, e As EventArgs)
|
||||
Public Event UpdateInstallerStarted(Sender As Object, e As EventArgs)
|
||||
|
||||
Public Property InstallAsAdmin As Boolean = True
|
||||
Public Property RestartHostApplication As Boolean = True
|
||||
Public Property AutomaticlyCloseHostApplication As Boolean = True
|
||||
Public Property UpdateDirURL As String
|
||||
Public Property UpdateInfoURL As String
|
||||
|
||||
Public Sub New(updateUrl As String)
|
||||
UpdateInfoURL = updateUrl
|
||||
UpdateDirURL = updateUrl.Remove(updateUrl.LastIndexOf("/"c))
|
||||
End Sub
|
||||
|
||||
Public Async Function Update() As Task
|
||||
Dim wc As New WebClient
|
||||
Dim updateInstallerZipPath As String = Path.Combine(MyTempPath, "Pilz.Updating.UpdateInstaller.zip")
|
||||
Dim updateInstallerPath As String = updateInstallerZipPath & "_unpacked"
|
||||
Dim updateInstallerExePath As String = Path.Combine(updateInstallerPath, "Pilz.Updating.UpdateInstaller.exe")
|
||||
|
||||
'Clean AppData
|
||||
For Each dir As String In Directory.GetDirectories(MyTempPath, "*", SearchOption.TopDirectoryOnly)
|
||||
Directory.Delete(dir, True)
|
||||
Next
|
||||
|
||||
'Download UpdateInfos
|
||||
Dim strUpdateInfos As String = Await wc.DownloadStringTaskAsync(UpdateInfoURL)
|
||||
Dim updateInfos As UpdateInfo() = JArray.Parse(strUpdateInfos).ToObject(Of UpdateInfo())
|
||||
|
||||
If updateInfos.Any Then
|
||||
'Order update infos from newest to oldest
|
||||
updateInfos = updateInfos.OrderByDescending(
|
||||
Function(n)
|
||||
Return n.Version.ToString &
|
||||
(Byte.MaxValue - n.State).ToString("X2") &
|
||||
n.Build.ToString("X4")
|
||||
End Function).ToArray
|
||||
|
||||
'Interagate with user
|
||||
Dim e As New UpdatesFoundEventArgs(updateInfos)
|
||||
RaiseEvent UpdatesFound(Me, e)
|
||||
|
||||
'Install updates
|
||||
If Not e.Cancel Then
|
||||
Dim updateInfo As UpdateInfo = updateInfos(0)
|
||||
Dim updatePackageZipFilename As String = $"{updateInfo.Version.ToString} {CByte(updateInfo.State)} {updateInfo.Build}.zip"
|
||||
Dim updatePackageZipPath As String = Path.Combine(MyTempPath, updatePackageZipFilename)
|
||||
Dim updatePackagePath As String = updatePackageZipPath & "_unpacked"
|
||||
|
||||
'Download UpdateInstaller
|
||||
Await wc.DownloadFileTaskAsync(UpdateDirURL & "/Pilz.Updating.UpdateInstaller.zip", updateInstallerZipPath)
|
||||
ZipFile.ExtractToDirectory(updateInstallerZipPath, updateInstallerPath)
|
||||
|
||||
'Download Update Package
|
||||
Await wc.DownloadFileTaskAsync(UpdateDirURL & "/" & updatePackageZipFilename, updatePackageZipPath)
|
||||
ZipFile.ExtractToDirectory(updatePackageZipFilename, updatePackagePath)
|
||||
|
||||
'Build process arguments
|
||||
Dim applicationExePath As String = Assembly.GetExecutingAssembly.Location
|
||||
Dim procArgs As String = $"restartHostApp#{RestartHostApplication} autoCloseHostApp#{AutomaticlyCloseHostApplication} ""updatePackage#{updatePackagePath}"" ""applicationPath#{applicationExePath}"""
|
||||
|
||||
'Finally start update installer to install updates
|
||||
Process.Start(updateInstallerExePath, procArgs)
|
||||
|
||||
'Interagate with user
|
||||
RaiseEvent UpdateInstallerStarted(Me, New EventArgs)
|
||||
End If
|
||||
Else
|
||||
RaiseEvent NoUpdatesFound(Me, New EventArgs)
|
||||
End If
|
||||
|
||||
wc.Dispose()
|
||||
End Function
|
||||
|
||||
End Class
|
||||
4
Pilz.Updating/packages.config
Normal file
4
Pilz.Updating/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user