Closed CWolffIF closed 5 years ago
The VersionConverter is a dependency for the DevExpress.XAF modules. it installs with them.
Is there something special with your build? you build from vs? is it on parallel?
hmm looks like the VersionConverter still uses resources even if there is no patching. Can you replace the Xpand.VersionConverter.ps1 from your packages folder.
using namespace System
using namespace System.IO
using namespace System.IO.Compression
using namespace System.Reflection
using namespace System.Text.RegularExpressions
using namespace Mono.Cecil
using namespace Mono.Cecil.pdb
param(
[parameter(Mandatory)]
[string]$projectFile,
[parameter(Mandatory)]
[string]$targetPath,
[string]$referenceFilter = "DevExpress*",
[string]$assemblyFilter = "Xpand.XAF.*"
)
$ErrorActionPreference = "Stop"
set-location $targetPath
# $VerbosePreference="Continue"
Write-Verbose "Running Version Converter on project $projectFile with target $targetPath"
$projectFileInfo = Get-Item $projectFile
[xml]$csproj = Get-Content $projectFileInfo.FullName
$references = $csproj.Project.ItemGroup.Reference
$dxReferences = $references | Where-Object { $_.Include -like "$referenceFilter" }
$root = $PSScriptRoot
"Loading Mono.Cecil"
$monoPath = "$root\mono.cecil.0.10.3\lib\net40"
if (!(Test-Path "$monoPath\Mono.Cecil.dll")) {
$client = New-Object System.Net.WebClient
$client.DownloadFile("https://www.nuget.org/api/v2/package/Mono.Cecil/0.10.3", "$root\mono.cecil.0.10.3.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[ZipFile]::ExtractToDirectory("$root\mono.cecil.0.10.3.zip", "$root\mono.cecil.0.10.3")
}
[Assembly]::Load([File]::ReadAllBytes("$monoPath\Mono.Cecil.dll")) | Out-Null
[Assembly]::Load([File]::ReadAllBytes("$monoPath\Mono.Cecil.pdb.dll")) | Out-Null
Add-Type @"
using Mono.Cecil;
public class MyDefaultAssemblyResolver : DefaultAssemblyResolver{
public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters){
try{
return base.Resolve(name, parameters);
}
catch (AssemblyResolutionException){
var assemblyDefinition = AssemblyDefinition.ReadAssembly(string.Format(@"$targetPath\{0}.dll", name.Name));
return assemblyDefinition;
}
}
}
"@ -ReferencedAssemblies @("$monoPath\Mono.Cecil.dll")
$devExpressAssemblyName = Invoke-Command {
Write-Verbose "Finding DX assembly name"
$dxAssemblyPath = Get-ChildItem $targetPath "$referenceFilter*.dll" | Select-Object -First 1
if ($dxAssemblyPath) {
$dxAssembly = [AssemblyDefinition]::ReadAssembly($dxAssemblyPath.FullName)
Write-Verbose "$($dxAssembly.Name.Name) found from $($dxAssemblyPath.FullName)"
$dxAssembly.Name
}
else {
$name = ($dxReferences | Where-Object { $_.Include -like "*Version*" } | Select-Object -First 1).Include
New-Object System.Reflection.AssemblyName($name)
}
} | Select-Object -last 1
if (!$devExpressAssemblyName) {
throw "Cannot find $referenceFilter version in $($projectFileInfo.Name)"
}
$references | Where-Object { $_.Include -like $assemblyFilter } | ForEach-Object {
"$targetPath\$([Path]::GetFileName($_.HintPath))", "$($projectFileInfo.DirectoryName)\$($_.HintPath)" | ForEach-Object {
if (Test-Path $_) {
$modulePath = (Get-Item $_).FullName
$readerParams = New-Object ReaderParameters
$readerParams.ReadWrite = $true
$readerParams.AssemblyResolver=New-Object MyDefaultAssemblyResolver
$readerParams.SymbolReaderProvider = New-Object PdbReaderProvider
$readerParams.ReadSymbols = $true
$moduleAssembly = [AssemblyDefinition]::ReadAssembly($modulePath, $readerParams)
Write-Verbose "Checking $modulePath references.."
$moduleAssembly.MainModule.AssemblyReferences.ToArray() | Write-Verbose
$needPatching=$false
$moduleAssembly.MainModule.AssemblyReferences.ToArray() | Where-Object { $_.FullName -like $referenceFilter } | ForEach-Object {
$nowReference = $_
Write-Verbose "Checking $_ reference..."
if ($nowReference.Version -ne $devExpressAssemblyName.Version) {
$moduleAssembly.MainModule.AssemblyReferences.Remove($nowReference)
$newMinor = "$($devExpressAssemblyName.Version.Major).$($devExpressAssemblyName.Version.Minor)"
$newName = [Regex]::Replace($nowReference.Name, ".(v[\d]{2}\.\d)", ".v$newMinor")
$regex = New-Object Regex("PublicKeyToken=([\w]*)")
$token = $regex.Match($nowReference).Groups[1].Value
$regex = New-Object Regex("Culture=([\w]*)")
$culture = $regex.Match($nowReference).Groups[1].Value
$newReference = [AssemblyNameReference]::Parse("$newName, Version=$($devExpressAssemblyName.Version), Culture=$culture, PublicKeyToken=$token")
$moduleAssembly.MainModule.AssemblyReferences.Add($newreference)
$moduleAssembly.MainModule.Types | ForEach-Object {
$moduleAssembly.MainModule.GetTypeReferences() | Where-Object { $_.Scope -eq $nowReference } |ForEach-Object {
$_.Scope = $newReference
}
}
Write-Verbose "$($_.Name) version changed from $($_.Version) to $($devExpressAssemblyName.Version)"
$needPatching=$true
}
else {
Write-Verbose "Versions ($($nowReference.Version)) matched nothing to do."
}
}
if ($needPatching){
$writeParams = New-Object WriterParameters
$writeParams.WriteSymbols=$true
$f = New-Object FileStream("$root\Xpand.snk", [FileMode]::Open)
$writeParams.StrongNameKeyPair = New-Object System.Reflection.StrongNameKeyPair ( $f)
$moduleAssembly.Write($writeParams)
$f.Dispose()
}
$moduleAssembly.Dispose()
}
}
}
now it will only go to the exception line if patching is to be done which is determined by looking the nugets installation folder.
let me know if this relaxed the problem, or should I try the mutext approach as well.
The DevExpress.XAF repository includes commit Update Build Version to ALl #380,VersionConverter: Does not release resources on error #380 that relate to this task. Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.
Thanks a lot for your contribution.
Thanks, it works.
Sorry,
but now is the problem in the Reactive Module.
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : ForEach-Object : Ausnahme beim Aufrufen von "ReadAssembly" mit 2 Argument(en): "Der Prozess kann nicht auf die Datei
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : "C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module.Win\bin\Debug\Xpand.XAF.Modules.Reactive.dll" zugreifen, da sie von
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : einem anderen Prozess verwendet wird."
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.ps1:87 Zeichen:109
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : + ... "$($projectFileInfo.DirectoryName)\$($_.HintPath)" | ForEach-Object {
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : + ~~~~
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [ForEach-Object], MethodInvocationException
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : IOException,Microsoft.PowerShell.Commands.ForEachObjectCommand
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error :
4>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module.Win\iXISXRM.Module.Win.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module.Win\bin\Debug\' } "" wurde mit dem Code 1 beendet.
do u see a way of reproducing it?
Der Prozess kann nicht auf die Datei
this is a side effect of a previous exception, can you uncomment this line https://github.com/eXpandFramework/DevExpress.XAF/blob/70f60fc02517ddaf180cd00c5a9c8cbc38b6824a/tools/Xpand.VersionConverter/Xpand.VersionConverter.ps1#L16 in your C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.13\build\Xpand.VersionConverter.ps1 and report back the VS output window contents the first time the error occurred
please update your packages, i belive all your issues are addressed
apologies the problem is still here, but I managed to reproduce it, soon will have a patch.
the workaround until the patch is to disable parallel builds
The DevExpress.XAF repository includes commit Cross process patching synchronization #380,DevExpress version is not resolved #380,Destroy AppDomain to release resource #380 that relate to this task. Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.
Thanks a lot for your contribution.
Unfortunately I couldn't find a way to repro the issue. Here the the steps I followed.
Install eXpandFramework in GAC
Set-ExecutionPolicy Bypass -Scope Process -Force;iex "$(([System.Net.WebClient]::new()).DownloadString('http://install.expandframework.com'));Install-Xpand -Assets @('Assemblies','Nuget','VSIX','Source') #-Version '18.2.704.0'"
Create a new XAF empty solution and open VS package manager console and type:
Install XpandPosh
Install-Module XpandPosh -MinimumVersion 1.9.5
Update to 4.6.1 as I wanted to install all modules.
Update-ProjectTargetFramework
Install all packages
Find-XpandPackage Xpand*|Install-Packge
Register the installed packages by paste the next snippet in the constructor of my agnostic module as instructed by readme.
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.ViewEditMode.ViewEditModeModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.SuppressConfirmation.SupressConfirmationModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.ModelViewInheritance.ModelViewInheritanceModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.MasterDetail.MasterDetailModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.CloneModelView.CloneModelViewModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.CloneMemberValue.CloneMemberValueModule));
RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.AutoCommit.AutoCommitModule));
Build the solution which failed in the first build complaining about a conflict in the system.valuetuple and suggesting to Enable Automatic Binding redirection in the properties of my csproject.
Build again and open VS designer with no errors.
for this I use the latest standalone packages from the lab which I will publish official soon.
eXpand.lab release 18.2.703.10 includes commit Update XAF modules nugets #380 that relate to this task. Please test if it addresses the problem. If you use nuget add our LAB NugetServer as a nuget package source in VS.
Thanks a lot for your contribution.
Hi Tolis,
I did everything like your instruction. But now I can´t build a Project anymore.
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : Cannot find DevExpress Version
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1:191 Zeichen:5
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + throw $_.Exception
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + ~~~~~~
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : RuntimeException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error :
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\iXISXRM.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\bin\Debug\' } "" wurde mit dem Code 1 beendet.
Hi,
I switched back to VersionConverter.1.0.16 (and the other Xpand.Modules) and I can compile.
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : Cannot find DevExpress Version C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1:191 Zeichen:5 C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + throw $_.Exception C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : +
~~~~~~ C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : RuntimeException C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\iXISXRM.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\bin\Debug' } "" wurde mit dem Code 1 beendet.
the cross cross process patch synchronization introduced in 1.0.17, and was required not only for this case but also for FeatureCenter as it had the same problem. This exception should be failry easy to resolve as it only about not finding which DX version to patch. So looking at the Version converter he have. https://github.com/eXpandFramework/DevExpress.XAF/blob/9ff066b84f67137f9b643ab768f9e762d4fd00c8/tools/Xpand.VersionConverter/Xpand.VersionConverter.ps1#L53-L89
DX version is detected first from the csproj file references hintpath (hintpath should be valid if dx is not in gac e.g. nuget or u simply manully reference from a dir)
$hintPath = $dxReferences.HintPath | foreach-Object {
if ($_) {
$path = $_
if (![path]::IsPathRooted($path)) {
$path = "$((Get-Item $projectFile).DirectoryName)\$_"
}
if (Test-Path $path) {
}
}
} | Where-Object { $_ } | Select-Object -First 1
if ($hintPath ) {
Write-Verbose "$($dxAssembly.Name.Name) found from $hintpath"
Use-Object($assembly = Get-MonoAssembly $hintPath) {
$assembly.name.version
}
}
apparently for this case HintPath was null for all your dx references. (You could of course manually add in one and help detection but we want to automate it.)
if hintpath fails 2nd attempt is to look in the bin directory of your project for a dx assembly and get its version
$dxAssemblyPath = Get-ChildItem $targetPath "$referenceFilter*.dll" | Select-Object -First 1
if ($dxAssemblyPath) {
Write-Verbose "$($dxAssembly.Name.Name) found from $($dxAssemblyPath.FullName)"
Use-Object($assembly = Get-MonoAssembly $dxAssemblyPath.FullName) {
$assembly.name.version
}
}
for this case apparently your bin was empty of dx assemblies, again u can put any dx assembly manual there and the exception will not throw.
3rd attempt if hintpath and bin fail is to look in the gac for any dx assembly for the major DX version found from your csproj
$dxReference=($dxReferences|Select-Object -First 1).Include
$dxAssembly=Get-ChildItem "$env:windir\Microsoft.NET\assembly\GAC_MSIL" *.dll -Recurse|Where-Object{$_ -like "*$dxReference.dll"}
if ($dxAssembly){
Use-Object($assembly = Get-MonoAssembly $dxAssembly.FullName) {
$assembly.name.version
}
}
if all 3 fail then u get the exception u posted. But now my question is how VS finds your DX assemblies? It looks like hinpath is null gac is null and bin is empty.
I think I have the answer what this script returns?
Get-ChildItem ((Get-ItemProperty -LiteralPath HKLM:\Software\Wow6432Node\Microsoft\.NETFramework\AssemblyFolders\Xpand)."(Default)") DevExpress*.dll|Select-Object -First 1
Hi,
in that path there are no DevExpress*.dll.
so whats the path of your DX assemblies in your project? expand the references node, select a dx assembly and post the path that displayed there?
C:\Program Files (x86)\DevExpress 18.2\Components\Bin\Framework\DevExpress.ExpressApp.v18.2.dll
so dx is in your gac right?
Yes
can u edit the csproj and post how a dx assembly reference is declared?
<Reference Include="DevExpress.ExpressApp.v18.2, Version=18.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
also verify that this query returns dx assemblies
Get-ChildItem "$env:windir\Microsoft.NET\assembly\GAC_MSIL" DevExpress*18.2*.dll -Recurse
Works
Verzeichnis: C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\DevExpress.ExpressApp.v18.2\v4.0_18.2.7.0__b88d1754d700e49a
Mode LastWriteTime Length Name
-a---- 29.04.2019 07:34 2068216 DevExpress.ExpressApp.v18.2.dll
excellent wait for my next patch please I will improvwe the detection algorithm and we are set
can you replace the VersionConverter.ps1 in your packages folder with this
using namespace System
using namespace System.Threading
using namespace System.Reflection
using namespace System.IO
using namespace System.IO.Compression
using namespace System.Reflection
using namespace System.Text.RegularExpressions
using namespace Mono.Cecil
using namespace Mono.Cecil.pdb
param(
[string]$projectFile,
[string]$targetPath,
[string]$referenceFilter = "DevExpress*",
[string]$assemblyFilter = "Xpand.XAF.*"
)
# $VerbosePreference = "Continue"
$ErrorActionPreference = "Stop"
function Use-Object {
[CmdletBinding()]
param (
[Object]$InputObject,
[Parameter(Mandatory = $true)]
[scriptblock]$ScriptBlock
)
$killDomain
try {
. $ScriptBlock
}
catch {
$killDomain = $true
}
finally {
if ($null -ne $InputObject -and $InputObject -is [System.IDisposable]) {
$InputObject.Dispose()
if ($killDomain) {
Stop-Process -id $pid
}
}
}
}
function Get-MonoAssembly($path, [switch]$Write) {
$readerParams = New-Object ReaderParameters
if ($Write) {
$readerParams.ReadWrite = $true
$readerParams.SymbolReaderProvider = New-Object PdbReaderProvider
$readerParams.ReadSymbols = $true
}
$readerParams.AssemblyResolver = New-Object MyDefaultAssemblyResolver
[ModuleDefinition]::ReadModule($path, $readerParams).Assembly
}
function Get-DevExpressVersion($targetPath, $referenceFilter,$dxReferences) {
Write-Verbose "Finding DevExpress version..."
$hintPath = $dxReferences.HintPath | foreach-Object {
if ($_) {
$path = $_
if (![path]::IsPathRooted($path)) {
$path = "$((Get-Item $projectFile).DirectoryName)\$_"
}
if (Test-Path $path) {
[path]::GetFullPath($path)
}
}
} | Where-Object { $_ } | Select-Object -First 1
if ($hintPath ) {
Write-Verbose "$($dxAssembly.Name.Name) found from $hintpath"
Use-Object($assembly = Get-MonoAssembly $hintPath) {
$assembly.name.version
}
}
else {
$dxAssemblyPath = Get-ChildItem $targetPath "$referenceFilter*.dll" | Select-Object -First 1
if ($dxAssemblyPath) {
Write-Verbose "$($dxAssembly.Name.Name) found from $($dxAssemblyPath.FullName)"
Use-Object($assembly = Get-MonoAssembly $dxAssemblyPath.FullName) {
$assembly.name.version
}
}
else {
$include=($dxReferences|Select-Object -First 1).Include
$dxReference=$include -imatch 'DevExpress[^,]*'
$dxAssembly=Get-ChildItem "$env:windir\Microsoft.NET\assembly\GAC_MSIL" *.dll -Recurse|Where-Object{$_ -like "*$dxReference.dll"}
if ($dxAssembly){
Use-Object($assembly = Get-MonoAssembly $dxAssembly.FullName) {
$assembly.name.version
}
}
else{
throw "Cannot find DevExpress Version"
}
}
}
}
function Update-Version($modulePath, $dxVersion) {
Use-Object($moduleAssembly = Get-MonoAssembly $modulePath -Write) {
$moduleReferences = $moduleAssembly.MainModule.AssemblyReferences
Write-Verbose "References:"
$moduleReferences | Write-Verbose
$needPatching = $false
$moduleReferences.ToArray() | Where-Object { $_.FullName -like $referenceFilter } | ForEach-Object {
$dxReference = $_
Write-Verbose "Checking $_ reference..."
if ($dxReference.Version -ne $dxVersion) {
$moduleReferences.Remove($dxReference)
$newMinor = "$($dxVersion.Major).$($dxVersion.Minor)"
$newName = [Regex]::Replace($dxReference.Name, ".(v[\d]{2}\.\d)", ".v$newMinor")
$regex = New-Object Regex("PublicKeyToken=([\w]*)")
$token = $regex.Match($dxReference).Groups[1].Value
$regex = New-Object Regex("Culture=([\w]*)")
$culture = $regex.Match($dxReference).Groups[1].Value
$newReference = [AssemblyNameReference]::Parse("$newName, Version=$($dxVersion), Culture=$culture, PublicKeyToken=$token")
$moduleReferences.Add($newreference)
$moduleAssembly.MainModule.Types | ForEach-Object {
$moduleAssembly.MainModule.GetTypeReferences() | Where-Object { $_.Scope -eq $dxReference } | ForEach-Object {
$_.Scope = $newReference
}
}
Write-Verbose "$($_.Name) version will changed from $($_.Version) to $($dxVersion)"
$needPatching = $true
}
else {
Write-Verbose "Versions ($($dxReference.Version)) matched nothing to do."
}
}
if ($needPatching) {
Write-Verbose "Patching $modulePath"
$writeParams = New-Object WriterParameters
$writeParams.WriteSymbols = $true
$key = [byte[]]::new(0)
$key = [File]::ReadAllBytes("$root\Xpand.snk")
$writeParams.StrongNameKeyPair = [System.Reflection.StrongNameKeyPair]($key)
$moduleAssembly.Write($writeParams)
}
}
}
try {
$mtx = [Mutex]::OpenExisting("VersionConverterMutex")
}
catch {
$mtx = [Mutex]::new($true, "VersionConverterMutex")
}
try {
set-location $targetPath
Write-Verbose "Running Version Converter on project $projectFile with target $targetPath"
$projectFileInfo = Get-Item $projectFile
[xml]$csproj = Get-Content $projectFileInfo.FullName
$references = $csproj.Project.ItemGroup.Reference
$dxReferences = $references | Where-Object { $_.Include -like "$referenceFilter" }
$root = $PSScriptRoot
Write-Verbose "Loading Mono.Cecil"
$monoPath = "$root\mono.cecil.0.10.3\lib\net40"
if (!(Test-Path "$monoPath\Mono.Cecil.dll")) {
$client = New-Object System.Net.WebClient
$client.DownloadFile("https://www.nuget.org/api/v2/package/Mono.Cecil/0.10.3", "$root\mono.cecil.0.10.3.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[ZipFile]::ExtractToDirectory("$root\mono.cecil.0.10.3.zip", "$root\mono.cecil.0.10.3")
}
[System.Reflection.Assembly]::Load([File]::ReadAllBytes("$monoPath\Mono.Cecil.dll")) | Out-Null
[System.Reflection.Assembly]::Load([File]::ReadAllBytes("$monoPath\Mono.Cecil.pdb.dll")) | Out-Null
Add-Type @"
using Mono.Cecil;
public class MyDefaultAssemblyResolver : DefaultAssemblyResolver{
public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters){
try{
return base.Resolve(name, parameters);
}
catch (AssemblyResolutionException){
var assemblyDefinition = AssemblyDefinition.ReadAssembly(string.Format(@"$targetPath\{0}.dll", name.Name));
return assemblyDefinition;
}
}
}
"@ -ReferencedAssemblies @("$monoPath\Mono.Cecil.dll")
$dxVersion = Get-DevExpressVersion $targetPath $referenceFilter $dxReferences
$references | Where-Object { $_.Include -like $assemblyFilter } | ForEach-Object {
"$targetPath\$([Path]::GetFileName($_.HintPath))", "$($projectFileInfo.DirectoryName)\$($_.HintPath)" | ForEach-Object {
if (Test-Path $_) {
$modulePath = (Get-Item $_).FullName
Write-Verbose "Checking $modulePath references.."
Update-Version $modulePath $dxVersion
}
}
}
}
catch {
throw $_.Exception
}
finally {
$mtx.ReleaseMutex()
$mtx.Dispose()
}
and let me know if it works, also delete all XPand* folders inside the Packages folder except versionconverter of course so that they will patched again.
Hi Tolis,
I patched all to the new version from nuget.org and than replaced the VersionConverter.ps1 Code.
It works and has many "true"......
------ Erstellen gestartet: Projekt: iXISFramework.Module.Win, Konfiguration: Debug Any CPU ------ True True True True True True True True True True True True True True True True True True C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module.Win\Controllers\IFLockController.cs(40,30,40,32): warning CS0168: Die Variable "ex" ist deklariert, wird aber nie verwendet. iXISFramework.Module.Win -> C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module.Win\bin\Debug\iXISFramework.Module.Win.dll
true is for each patched references i will hide it, thnks for testing!
wait for the official and update.
Hi Tolis,
actual I "...the workaround until the patch is to disable parallel builds.." set to 1. If I set then back to 8, I got following error message:
4>------ Erstellen gestartet: Projekt: iXISFramework.Module.Win, Konfiguration: Debug Any CPU ------
3> True
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : Ausnahme beim Aufrufen von "ReleaseMutex" mit 0 Argument(en): "Die Objektsynchronisationsmethode wurde von einem
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : nicht synchronisierten Codeblock aufgerufen."
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1:195 Zeichen:5
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + $mtx.ReleaseMutex()
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + ~~~~~~~
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : ApplicationException
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error :
3>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.17\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\iXISXRM.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\bin\Debug\' } "" wurde mit dem Code 1 beendet.
hmm this smells some kind of mistake following all my directions, let's go for a lab build to make sure everything is setup ok. Please update the packages when the bot notifies.
I guess you can consume lab builds right? you setup the lab package source in your vs already?
The lab nugets are at https://xpandnugetserver.azurewebsites.net/nuget right?
yes
The DevExpress.XAF repository includes commit Improve Dx verions detection algorithm #380 that relate to this task. Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.
Thanks a lot for your contribution.
sorry this a bad release do not use it wait for the next one
The DevExpress.XAF repository includes commit Improve Dx verions detection algorithm #380 that relate to this task. Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.
Thanks a lot for your contribution.
this a good release
Hi Tolis,
something went wrong. The actual Lab Version of the VersionConverter is 1.0.18 (29.04.2019 16:51) and the error is back. But the Code from above doesn´t work anymore.
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : Cannot find DevExpress Version
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.ps1:192 Zeichen:5
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + throw $_.Exception
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + ~~~~~~
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : RuntimeException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error :
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\iXISFramework.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\bin\Debug\' } "" wurde mit dem Code 1 beendet.
Hi,
with some patient we can find what is happening here.
I see my changes are distributed ok https://github.com/eXpandFramework/DevExpress.XAF/blob/bad2bbdd30e6c9dc07b4110f1c71585d27e70c35/tools/Xpand.VersionConverter/Xpand.VersionConverter.ps1#L81-L82
to test why it does not find it in gac please modify the VersionCOnverter.ps1
Write-Verbose "Include=$Include"
Write-Verbose "DxReference=$dxReference"
also note that Xpand lab pass fine. Especially FeatureCenter uses multiple packages over 12 parallel jobs so we have an indicator that we are on the right path.
Hi,
what do you mean with "3. Remove Xpand.XAF.* folders from the Packages Rebuild and post the output"?
the output after 1. and 2. is
AUSFÜHRLICH: Running Version Converter on project
C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\iXISFramework.Module.csproj with target
C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\bin\Debug\
AUSFÜHRLICH: Loading Mono.Cecil
AUSFÜHRLICH: Finding DevExpress version...
AUSFÜHRLICH: Include=DevExpress.Data.v18.2, Version=18.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a,
processorArchitecture=MSIL
AUSFÜHRLICH: DxReference=True
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : Cannot find DevExpress Version
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.ps1:196 Zeichen:5
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + throw $_.Exception
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + ~~~~~~
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : RuntimeException
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error :
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.18\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\iXISFramework.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISFramework.Module\bin\Debug\' } "" wurde mit dem Code 1 beendet.
Inside the Packages folder there are Xpand.XAF.* folders for each package you installed. The assemblies might be already patched so the code won't reach the line in question. Removing them will and Rebuild will assure patching again.
you might also want to clear your local nuget cache in this machine, just in case God is laughing with us
& nuget.exe locals all -clear
or if you have XPandPOsh installed just do
Clear-NugetCache
Hi,
OK I cleared everything. I checked the lines 80+ with some messages
$include=($dxReferences|Select-Object -First 1).Include $dxReference=$include -imatch 'DevExpress[^,]*'
Write-Verbose "Include=$Include"
Write-Verbose "DxReference=$dxReference"
$dxAssembly=Get-ChildItem "$env:windir\Microsoft.NET\assembly\GAC_MSIL" *.dll -Recurse|Where-Object{$_ -like "*$dxReference.dll"}
Write-Verbose "ifaktor 1"
if ($dxAssembly){
Write-Verbose "ifaktor 2"
Use-Object($assembly = Get-MonoAssembly $dxAssembly.FullName) {
Write-Verbose "ifaktor 3"
$assembly.name.version
}
}
else{
Write-Verbose "ifaktor else"
throw "Cannot find DevExpress Version"
}
The Output is AUSFÜHRLICH: Loading Mono.Cecil AUSFÜHRLICH: Finding DevExpress version... AUSFÜHRLICH: Include=DevExpress.Data.v18.2, Version=18.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL AUSFÜHRLICH: DxReference=True AUSFÜHRLICH: ifaktor 1 AUSFÜHRLICH: ifaktor else
It did not go to Write-Verbose "ifaktor 2" so the if ($dxAssembly)
I think the $dxAssembly is null
$dxReference is true (boolean) so $dxAssembly=Get-ChildItem "$env:windir\Microsoft.NET\assembly\GACMSIL" *.dll -Recurse|Where-Object{$ -like "*$dxReference.dll"} is null
Hi,
I got often Errors building my project, cause the VersionConvertrer is used by another process. The VersionConverter is installed in every Sub-Project (Module, Module-Win, Win). Is this correct?
C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : New-Object : Ausnahme beim Aufrufen von ".ctor" mit 2 Argument(en): "Der Prozess kann nicht auf die Datei 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : "C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.snk" zugreifen, da sie von einem anderen 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : Prozess verwendet wird." 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : In C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.ps1:108 Zeichen:18
2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : + ... $f = New-Object FileStream("$root\Xpand.snk", [FileMode]::Open ... 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : +
~~~~~~~~~~~~~ 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error : + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand 2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error :2>C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.targets(4,9): error MSB3073: Der Befehl "powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'C:\DevProjects\NuGetPackages\Xpand.VersionConverter.1.0.11\build\Xpand.VersionConverter.ps1' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\iXISXRM.Module.csproj' 'C:\DevProjects\iXISJH\iXISXRM\iXISXRM.Module\bin\Debug\' } "" wurde mit dem Code 1 beendet.