Correct way of using msbuild xmlpoke - xpath

I am trying to set the value for element if the element value matches
"ABB Automation Builder Platform.abpkg"
My script uses xmlpoke as below:
<XmlPoke
Namespaces="<Namespace Prefix='x' Uri='http://www150.abb.com/spaces/DAE-1/ProdDev/Shared%20Documents/40%20DAE%20Installer/Design/XML%20Descriptions/DAEInstaller_Description_StyleSheet' >"
Query="x:ProductUpdate/x:Packages/x:Package[x:FileName='ABB Automation Builder Platform.abpkg']/x:FileHash"
XmlInputPath="Output\update.manifest"
Value="Ajay Vishwakarma"/>
The xml I am trying to modify is below:
<?xml version="1.0" encoding="utf-8"?>
<ProductUpdate xmlns="http://www150.abb.com/spaces/DAE-1/ProdDev/Shared%20Documents/40%20DAE%20Installer/Design/XML%20Descriptions/DAEInstaller_Description_StyleSheet">
<Strings>
<Text id="1">
<Neutral>ABB Automation Builder 1.0 \nService Release 1</Neutral>
<Localized culture="en">ABB Automation Builder 1.0 \nService Release 1</Localized>
<Localized culture="de">ABB Automation Builder 1.0 \nService Release 1</Localized>
<Localized culture="fr">ABB Automation Builder 1.0 \nService Release 1</Localized>
<Localized culture="es">ABB Automation Builder 1.0 \nService Release 1</Localized>
<Localized culture="zh">ABB Automation Builder 1.0 \nService Release 1</Localized>
</Text>
<Text id="2">
<Neutral>Information\ABB Automation Builder Upate Package V1_0_1Description_en.htm</Neutral>
<Localized culture="en">Information\ABB Automation Builder Upate Package V1_0_1Description_en.htm</Localized>
<Localized culture="de">Information\ABB Automation Builder Upate Package V1_0_1Description_de.htm</Localized>
<Localized culture="fr">Information\ABB Automation Builder Upate Package V1_0_1Description_fr.htm</Localized>
<Localized culture="es">Information\ABB Automation Builder Upate Package V1_0_1Description_es.htm</Localized>
<Localized culture="zh">Information\ABB Automation Builder Upate Package V1_0_1Description_zh.htm</Localized>
</Text>
</Strings>
<ReleaseType>ServicePack</ReleaseType>
<ProductName>$1</ProductName>
<Version>1.0.1</Version>
<Description>$2</Description>
<License>
<Name>$3</Name>
<ID>45668677876463</ID>
<Description>$4</Description>
<Version>1.0.1</Version>
<DescriptionVersion>$5</DescriptionVersion>
<DescriptionTypeVersion>1.0.0</DescriptionTypeVersion>
<ToAccept>true</ToAccept>
</License>
<Copyright>$6</Copyright>
<MinimumRequiredVersion>1.0.0</MinimumRequiredVersion>
<Packages>
<Package>
<Name>ABB Automation Builder Platform Update Package</Name>
<Description>ABB Automation Builder Platform Update Package</Description>
<FileName>ABB Automation Builder Platform.abpkg</FileName>
<FileHash>AjayVishwakarma</FileHash>
<FileDownload>
</FileDownload>
<InstallerData>
<Component>
<Name>ABB Automation Builder Package Manager</Name>
<ID>{F5B05B3F-9FA5-476E-BDD3-DB1397CABF4C}</ID>
<Version>1.0.1.0</Version>
<InstallAlways>true</InstallAlways>
</Component>
</InstallerData>
</Package>
<Package>
<Name>PLC AC500 Update Package</Name>
<Description>PLC AC500 Update Package</Description>
<FileName>PLC - AC500.abpkg</FileName>
<FileHash>8652d588d4c1fe70e0e06a9cf3e09193</FileHash>
<FileDownload>
</FileDownload>
<InstallerData>
<Component>
<Name>Codesys</Name>
<ID>{F8A33E2A-5B6A-474B-8ED2-293B4982D4E6}</ID>
<Version>2.3.9.41</Version>
</Component>
<Component>
<Name>Target Support Package</Name>
<ID>{CC764263-BEF5-4060-AA49-0366AB2E868B}</ID>
<Version>1.0.1.0</Version>
</Component>
<Component>
<Name>Control Builder Plus documentation</Name>
<ID>{484D63DB-1EB6-4F4F-851F-7F7D7D34A396}</ID>
<Version>1.0.1.0</Version>
</Component>
</InstallerData>
</Package>
</Packages>
</ProductUpdate>
XmlPoke task fails to update element value and gives message "Made 0 replacement(s)."
I have also tries passing query like
Query="//x:ProductUpdate/x:Packages/x:Package[x:FileName='ABB Automation Builder Platform.abpkg']/x:FileHash" OR
Query=".//x:ProductUpdate/Packages/Package[FileName='ABB Automation Builder Platform.abpkg']/FileHash"
I want to know if I am doing it the wrong way?
Please note that I don't want to make any changes in the namespace in my xml document.

You're not crazy.
That (hex coded) spaces in the original xml document in the namespace are throwing things off.
I don't have an answer.
But here is a suggestion.
I always use XmlPeek and then "build up" the Query.
<XmlPeek Namespaces="<Namespace Prefix='peanut' Uri='http://www150.abb.com/spaces/DAE-1/ProdDev/Shared%20Documents/40%20DAE%20Installer/Design/XML%20Descriptions/DAEInstaller_Description_StyleSheet'/>"
XmlInputPath=".\MyXmlFile.xml"
Query="//peanut:ProductUpdate">
<Output TaskParameter="Result" ItemName="Peeked" />
</XmlPeek>
<Message Text="#(Peeked)"/>
(Above with the XmlPeek, I have the top level Query "//ProductUpdate".
The Message #(Peeked) will show the xml fragment for there.
Then I can build up the query and see the results....and adjust as necessary. )
Anyway, back to the problem:
So the above will work IF you change the original Xml to be
<ProductUpdate xmlns="http://www150.abb.com/spaces/DAE-1/ProdDev/Shared Documents/40 DAE Installer/Design/XML Descriptions/DAEInstaller_Description_StyleSheet">
<Strings>
But with the original Xml with the the Hex values for the spaces.......the above won't work. :(
Anyway. That stinks. Its almost like the namespace (in the XmlPeek (or Poke) needs to be "double hexed encoded" or something.
Sorry, I gave it the college try.

I think you need to create a valid Namespace element. What you have is the opening tag, and not a self-closed element.
Instead of:
<Namespace Prefix='x'
Uri='http://www150.abb.com/spaces/..../DAEInstaller_Description_StyleSheet'>
You need:
<Namespace Prefix='x'
Uri='http://www150.abb.com/spaces/..../DAEInstaller_Description_StyleSheet'/>

Related

WinUI Registration Free WinRT Component

I followed the following tutorial on how to register a UWP registration free WinRT component https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/ but I continue to receive errors about the component not being registered.
I begin by creating a Propertysheet.props sheet, like in the tutorial:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup />
<ItemGroup>
<Reference Include="C:\Users\User\Solution\x64\Debug\Component\Component.winmd">
<IsWinmdFile>true</IsWinmdFile>
</Reference>
<ReferenceCopyLocationPaths Include="C:\Users\User\Solution\x64\Debug\Component\Component.dll">
<IsWinmdFile>false</IsWinmdFile>
</ReferenceCopyLocationPaths>
<!--<Reference Include="C:\Users\User\Solution\x64\Debug\Component2\Component2.winmd">
<IsWinmdFile>true</IsWinmdFile>
</Reference>
<ReferenceCopyLocationPaths Include="C:\Users\User\Solution\x64\Debug\Component2\Component2.dll">
<IsWinmdFile>false</IsWinmdFile>
</ReferenceCopyLocationPaths>-->
</ItemGroup>
</Project>
When the solution is compiled, the Winmd and the dll for Component are added to the DUALITY.exe folder, but only the Winmd for Component2 has been auto added so I remmed it out for now. I then add the Propertysheet.props to the Application project using the properties manager utility. This disabled the ability to add reference, but it still works as though it has been added. My app.manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Application.app"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
<file name="Component.dll">
<activatableClass
name="Component.SubNamespace.Class"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>
<!--<file name="Component2.dll">
<activatableClass
name="Component.PeregrineX12"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>-->
</assembly>
There were concerns about Namespace and I itterated through a few possibilities. I get an error in my Appmanifest.xml at line 39:
"DEP0700: Registration of the app failed. [0x80080204] error 0xC00CE012: App manifest validation error: The app manifest must be valid as per schema: Line 39, Column 8, Reason: Content for element '{http://schemas.microsoft.com/appx/manifest/foundation/windows10}InProcessServer' is incomplete according to the DTD/Schema. Expecting: {http://schemas.microsoft.com/appx/manifest/foundation/windows10}ActivatableClass."
and the Appmanifest.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build">
<Identity Name="837f0535-5d07-4290-983b-a49988c57b12" Publisher="CN=User" Version="1.0.0.0" ProcessorArchitecture="x64" />
<Properties>
<DisplayName>Application</DisplayName>
<PublisherDisplayName>User</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.22000.0" MaxVersionTested="10.0.22000.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<PackageDependency Name="Microsoft.WindowsAppRuntime.1.1" MinVersion="1001.524.1918.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.30704.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.30704.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
</Dependencies>
<Resources>
<Resource Language="EN-US" />
</Resources>
<Applications>
<Application Id="App" Executable="Application.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="Application" Description="DUALITY" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>Component.dll</Path>
</InProcessServer>
</Extension>
</Extensions>
<build:Metadata>
<build:Item Name="cl.exe" Version="19.31.31107.0" />
<build:Item Name="OptimizingToolset" Value="None" />
<build:Item Name="TargetRuntime" Value="Native" />
<build:Item Name="Microsoft.UI.Xaml.Markup.Compiler.dll" Version="1.0.0.0" />
<build:Item Name="Microsoft.UniversalCRT.Debug" Version="10.0.22000.0" />
<build:Item Name="makepri.exe" Version="10.0.22621.1 (WinBuild.160101.0800)" />
</build:Metadata>
</Package>
At this point, this was the first time an attempt was made by the framework to register the dll. This is all of the information I have collected from documentation, at this time. As can be seen ActivatableClass was not added and I'm pretty sure it should have been.
I'm going to re-summarize here, based on what I have come to, going through more of the documentation.
When you create a WinUI App, you can create a Packaged app with a packaging project or without. Here was my first mistake. The second project template is still a Packaged App and not an Unpackaged App. So keep that in mind while choosing your approach. The above tutorial says that the tutorial is specific to Unpackaged Apps, but it is applicable to both Packaged and Unpackaged Apps.
The tutorial describes how to consume WinRT Components calling it Registration Free. But WinRT is a Registration Free framework. Calling it Registration Free was misleading. Registration Free simply meant that it uses a manifest and doesn't mean you can gain access to the component without registering it with the App. Unless late binding (calling plugins), you will have to follow the Registration Free in application registration.
When making a Packaged App I needed to include the NuGet package Microsoft.VCRTForwarders.140. The tutorial uses app.manifest to declare activatableClasses. This is a shortcut, and really, you need to use the Package.appxmanifest to acquire full framework functionality; like declaring Proxy-Stub Servers for Interfaces. I use the Propertysheet.props to include the winmds and move the dll's into the exe folder, instead of just making a reference to the winmd and manually copying the dll's.
Here I learned I wasn't actually making an Unpackaged App. To make an Unpackaged App, first I had to make a Packaged App with no packaging project. Then, WindowPackageType had to be set to None and AppxPackage to false in the project file. Package.appxmanifest had to be removed from the project. I no longer needed the NuGet. Instead I needed to install the required framework bits, and load the Bootstrapper. This enabled connectivity and started the winrt framework in the Unpackaged environment. When not late binding, I included the winmds and moved my dll's into the executable folder using the Propertysheet.props. In this way I was able to use winrt get_activation_factory to make Runtime Classes in WinUI Components. There was no single document that covered this.
I found the easiest way to late bind WinRT components was--in an unpackaged or packaged app--was to load the dll using WINRT_IMPL_LoadLibraryW from base.h and call the GetActivationFactory directly using WINRT_IMPL_GetProcAddress. The only problem with this was that the Xaml framework didn't just extend into the WinUI Component. Xaml content was unable to load in the loaded component dll. I believe there is a way to add Xaml functionality, but it looks like it mixes with legacy WRL code and Xaml islands.
My solution to this last problem was to start another WinUI process. I Loaded a sub App from an App as a driver for the code behind. Other than to have a call up application, I don't see why I'd personally use controls defined in WinUI component dll's, and will simply use the main processes to drive behind UI logic in modular WinRT dll's. Especially with my Desktop Application already being so modular. Need new UI functionality, make a new one off of a template. For my purposes this makes the most sense. WinUI, WinRT, and Windows::Foundation all work without Xaml. I even passed a SwapChainPanel to a WinUI Component dll to make late binding DirectX12 graphics pipelines, so we're doing good.

how to webservicetarget url dynamically in nlog for xamarin forms

how to web service target URL dynamically in NLog for Xamarin.Forms in NLog.Config file. need to get a to a variable instead of hardcoding.
<target name="webservice"
xsi:type="WebService"
url="{var:url}"
protocol="JsonPost"
proxyType="NoProxy"
namespace="{var:namespace}"
methodName ="InsertLogs"
encoding="utf-8">
<parameter name="Datetime" type="System.String" layout="${time}"/>
<parameter name="level" layout="${level}" />
</target>
You can load and modify your target at runtime and set the URL:
var target = LogManager.Configuration.FindTargetByName("webservice") as WebServiceTarget;
target.Url = new Uri("https://my.url/logs");
LogManager.ReconfigExistingLoggers();
Notice that NLog v5.0 adds Layout-support for Url-option.
There are NLog v5.0 pre-release available for try out.
See also: https://github.com/NLog/NLog/wiki/WebService-target

Xamarin Android Entity Framework Core linker issue

I used Entity Framework Core in one of my Xamarin Android apps. When I use SDK only as of the linker option then the app works properly.
However, when I use SDK and user assemblies add linker option, the app crashes as several Entity Framework Core related required classes are removed by the linker.
Let me know if there is anything I could do to preserve the classes.
Note: I already tried referencing the Entity Framework Core classes in a dummy class.
You have to configure the linker.
Create a new xml in your Android project, call it linker.xml
Set the build action to LinkDescription
Paste this code:
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.String">
<method name="Compare"></method>
<method name="CompareTo"></method>
<method name="ToUpper"></method>
<method name="ToLower"></method>
</type>
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Expression`1"></type>
<type fullname="System.Linq.Queryable"></type>
</assembly>
</linker>
More complex usage of EF Core is likely to require a few more types and methods added.
Apparently my case is much more complex. I changes the file to
<linker>
<assembly fullname="mscorlib">
<type fullname="System.String" />
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions*" />
<type fullname="System.Linq.Queryable*" />
</assembly>
<assembly fullname="System.Collections">
<type fullname="System.Collections.Generic*" />
</assembly>
</linker>
but it still didn't fix the issue. Did anybody figure out the complete exclusion list for the entity framework core to work?

TeamCity API work out how long investigation took to start?

Using the TeamCity API:
We are trying to put together a dashboard to work out how long from a build failing, it took for someone to assign themselves to an investigation for the build / project.
We cant find a way to do this as investigations are assigned to projects not builds so there is no way to find out when an investigation started for a particular build ?
If you need to get investigation for build configuration you may use the following REST API:
http://teamcity:8111/app/rest/investigations?locator=buildType:(id:XXXX)
For example, the following request
https://teamcity.jetbrains.com/app/rest/investigations?locator=buildType:(id:Epigenome_GenestackTests)
returns the following response, which has timestamp under assignment node:
<?xml version="1.0" encoding="UTF-8"?>
<investigations count="1" href="/app/rest/investigations?locator=buildType:(id:Epigenome_GenestackTests)">
<investigation id="buildType:(id:Epigenome_GenestackTests)" state="TAKEN" href="/app/rest/investigations/buildType:(id:Epigenome_GenestackTests)">
<assignee username="evgeny.kurbatsky" name="Evgeny.Kurbatsky" id="1107" href="/app/rest/users/id:1107" />
<assignment>
<user username="oleg" name="Oleg Shpynov" id="2" href="/app/rest/users/id:2" />
<timestamp>20160321T122158+0000</timestamp>
</assignment>
<scope>
<buildTypes count="1">
<buildType id="Epigenome_GenestackTests" name="Genestack Tests" paused="true" description="Fast tests" projectName="BioLabs :: Epigenome" projectId="Epigenome" href="/app/rest/buildTypes/id:Epigenome_GenestackTests" webUrl="https://teamcity.jetbrains.com/viewType.html?buildTypeId=Epigenome_GenestackTests" />
</buildTypes>
</scope>
<target anyProblem="true" />
<resolution type="whenFixed" />
</investigation>
</investigations>

My nupkg is incompatible with my Unified API app

I've made a NuGet package that has a lib/Xamarin.iOS10 folder with a dll inside it.
I've created a test project (an iOS unified API Single View App) and I try to add my package but I get this response:
Could not install package 'mypackage 1.0'. You are trying to install
this package into a project that targets 'Xamarin.iOS,Version=v1.0',
but the package does not contain any assembly references or content
files that are compatible with that framework. For more information,
contact the package author.
Extracting the file, I can verify that my dll is present.
This is the nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8">
<id>MyPackage</id>
<version>1.0</version>
<title>My Package</title>
<authors>Kristian</authors>
<owners>Kristian</owners>
<developmentDependency>true</developmentDependency>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Experiment Package</description>
<summary />
<language>en-US</language>
<tags></tags>
<dependencies>
<dependency id="Fody" version="1.29.3"/>
</dependencies>
</metadata>
<files>
<file src="../MyPackage.XamarinIOS/bin/iPhone/Release/MyPackage.dll" target="lib/Xamarin.iOS10/MyPackage.dll" />
</files>
</package>
Is there anything else I need to do? I am not using the new project.json format for my package.. I am using Xamarin Studio version 5.9.8.
Shouldn't that be:
target="lib/xamarinios10/MyPackage.dll"
Instead of your Xamarin.iOS10 path?

Resources