msdeploy + setParameters.xml, how to set web physical file location - file

This question has been danced around a bit, forgive me if it is a duplicate but I haven't been able to find an exact answer.
I am trying to create a Parameters.xml for deployment configuration that specifies the destination physical file folder for a web site. This is for an automated build using TeamCity, e.g. commandline using .deploy.cmd.
Can someone explain what I need to do?
Parameters.xml:
<parameter name="physicalPathLocation" description="Physical path where files for this Web service will be deployed." defaultValue="\" tags="PhysicalPath">
<parameterEntry kind="DestinationVirtualDirectory" scope="Default\ Web\ Site/iag\.application\.services\.exampleservice/" match="" />
</parameter>
And in SetParameters.xml
<setParameter name="physicalPathLocation" value="C:\MyFolder\MySite" />
I suspect my problem is in how I am declaring the scope but am unsure what needs to be done.

Assuming Default Web Site/iag.application.services.exampleservice is a virtual directory in IIS (DestinationVirtualDirectory is only valid for "applications"), you can probably just get away with removing the / suffix and not encoding it. (I've also removed the match attribute)
<parameter name="physicalPathLocation"
description="Physical path where files for this Web service will be deployed."
defaultValue="\"
tags="PhysicalPath"
>
<parameterEntry kind="DestinationVirtualDirectory"
scope="Default Web Site/iag.application.services.exampleservice" />
</parameter>
Keep in mind that you don't have to declare parameters before you set them. You could just as easily declare the full parameter and set it at the same time:
<setParameter name="physicalPathLocation"
kind="DestinationVirtualDirectory"
scope="Default Web Site/iag.application.services.exampleservice"
value="C:\MyFolder\MySite" />

Related

WiX installer can't open config file

I have a WPF application and I've created an MSI to install it with the WixToolset 3.11 and Visual Studio Extension 2019. I'm trying to add either XmlFile or XmlConfig item to change values in the config file. I'm getting the following error:
Failed to open XML file C:\Program Files(x86)\CO Apps\Main App\OurApp.exe.config. system error: -2147024786
The file path is the full filepath because I gave it the full path trying to resolve the issue. Here's the important parts of the wxs file
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wixutil="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="9E76F000-5525-4BDF-8262-AE46B035D9CE"
Name="Our App"
Language="1033"
Version="2.0.0.0"
Manufacturer="CO Apps"
UpgradeCode="7CFB1B51-F5D5-4AD4-A509-F5C9BC05F875">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Our production application." />
<Directory Id="ProgramFilesFolder">
<Directory Id="VTAPPSDIR" Name="CO Apps">
<Directory Id="INSTALLFOLDER" Name="Our App">
<Component Id="MainExecutable" Guid="748368D7-7581-4809-A8FE-DFB1093D6A02">
<File Id="MainFile" Name="$(var.OurApp.TargetFileName)" DiskId="1" Source="$(var.OurApp.TargetDir)OurApp.exe" KeyPath="yes"></File>
<File Id="OurApp.exe.config" ReadOnly="no" Source="$(var.OurApp.TargetDir)OurApp.exe.config"></File>
... More File items for DLLs
<wixutil:XmlFile Id="SetAppMode" Action="setValue" File="C:\Program Files (x86)\CO Apps\Our App\OurApp.exe.confg" ElementPath="configuration/userSettings/OurApp.Properties.Settings/setting/AppMode/value" Value="Main" />
</Directory>
</Directory>
</Directory>
So I'm trying to set the "AppMode" value to "Main" when this installs. What I'm trying to set isn't the point it's that it can't seem to find or open the file. I've tried putting the XmlFile in its own component. I've tried several variations of File paths including [INSTALLDIR] and [INSTALLLOCATION] and the filename by itself. Without that line everything works great. With that line in, I get the error and it rolls back the install. I also tried XmlConfig instead of XmlFile:
<wixutil:XmlConfig Id="ClearConfigAppMode" Action="delete" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" Name="AppMode" />
<wixutil:XmlConfig Id="SetAppMode" Action="create" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" On="install" Node="element">
<wixutil:XmlConfig Id="SetConfigAppModeName" ElementId="SetAppMode" File="[INSTALLLOCATION]OurApp.exe.config" Name="name" Value="AppMode" />
<wixutil:XmlConfig Id="SetConfigAppModeSerializeAs" ElementId="SetAppMode" File="[INSTALLLOCATION]OurApp.exe.config" Name="serializeAs" Value="String" />
</wixutil:XmlConfig>
<wixutil:XmlConfig Id="SetAppModeValue" Action="create" File="[INSTALLLOCATION]OurApp.exe.config" ElementPath="userSettings/OurApp.Properties.Settings" On="install" Node="element" Sequence="2">
<wixutil:XmlConfig Id="SetAppModeVAlueMain" ElementId="SetAppModeValue" File="[INSTALLLOCATION]OurApp.exe.config" Name="Value" Value="Main" />
</wixutil:XmlConfig>
Since XmlConfig doesn't have setValue on an existing element I used the delete action to remove the item for use in development and insert a new one. Same error. It happens logged on as myself or as Administrator. Does anyone have a working example of WiX with WPF creating a MSI? I'm not looking for something as complex as WixBA. I just need to modify the app.exe.config file on install.
Thanks,
Mike
Example: Though I rarely use this feature, I have this working example here (my test project for XML): https://github.com/glytzhkof/WiXUpdateXmlFile. Snippets of the sample here and here.
Disclaimer: I am not sure if follows best practice for XML updates, since I prefer to do XML updates from application launch code instead - if possible (single source, easier debugability and in general more familiar territory for most developers).
app.config/web.config appsettings: Maybe check out this answer regarding appsettings or this answer (looks better) - just for your review, not necessarily a suggestion. Keeping deployed files read-only helps a lot to overwrite them reliably during updates and the file you generate can be kept untouched by the installer (the file is de-coupled from installer - it never touches them). Or as I wrote: HKCU can also be used to write "the few settings you actually have to change". Not so nice conceptually?
Clouded Settings: Personally I think settings should never be file-based but clouded in our day and age (kept in a remote database). See section 6 and 7 here. How realistic this is for your application I don't know. New challenges and problems - no doubt (network issues, firewalls, launch problems, etc...), but benefits: versioned settings, recovery and management (enforce new settings). Not sure about all the practicalities - never been involved that much, but would love to get rid of settings files - especially for corporate apps. However, sometimes nice concepts don't meet reality well - maybe it is too involved?

Unable to push vespa metrics to cloudwatch

Basically I need to monitor vespa metrics and for that I am trying to implement method to push metrics to cloudwatch.
This is the document that I am referring to https://docs.vespa.ai/documentation/monitoring.html
I have added the credentials file and putMetricData permission in the IAM role attached. The service.xml file that I am using in my code looks like this:
<admin version="2.0">
<adminserver hostalias="admin0"/>
<configservers>
<configserver hostalias="admin0"/>
</configservers>
<monitoring>
</monitoring>
<metrics>
<consumer id="my-cloudwatch">
<metric-set id="vespa" />
<cloudwatch region="ap-south-1" namespace="vespa">
<shared-credentials file="~/.aws/credentials" profile="default" />
</cloudwatch>
</consumer>
</metrics>
</admin>
I have deployed the code using vespa-deploy prepare application.zip && vespa-deploy activatebut I am still not seeing any metrics updated on my cloudwatch.
Also, I have tried to add:
<monitoring>
<interval>1</interval>
<systemname>vespa</systemname>
</monitoring>
But getting this error when deploying:
Request failed. HTTP status code: 400
Invalid application package: default.default: Error loading model: XML error in services.xml: element "interval" not allowed here; expected the element end-tag [9:16], input:
How can I fix this issue. Or atleast debug the issue that I am facing.
I suggest to use absolute path to the credentials file, as the ~ may not resolve to the directory you intended at runtime.
A couple more things:
I recommend using the default metric set, as vespa contains a lot of metrics, which will drive your CloudWatch cost higher. If you need additional metrics, you can add them with the metric tag inside consumer.
The monitoring element doesn't do anything useful in this context, so you should just drop it.
If you still don't see any metrics, please check for warnings or errors in the vespa log file (use vespa-logfmt) and the Telegraf log file: /opt/vespa/logs/telegraf/telegraf.log. (Vespa uses Telegraf internally to emit metrics to CloudWatch.)

Codename One - tests.dat file needed when using build.unitTest=1

I created a test extending the AbstractTest class. The test works correctly in Netbeans: I right-click on the project name, then on "Test". Of course the Netbeans test in done in the Codename One Simulator. I want to repeat the test on several real devices, as I asked in "Codename One - Test Recorder: execute a test on a real device"
So I added the build.unitTest=1 build hint and I checked that my build.xml contains:
<target name="test-for-ios-device" depends="clean,copy-ios-override,copy-libs,compile-test,clean-override">
<codeNameOne
jarFile="${dist.jar}"
displayName="${codename1.displayName}"
packageName = "${codename1.packageName}"
mainClassName = "${codename1.mainName}"
version="${codename1.version}"
icon="${codename1.icon}"
vendor="${codename1.vendor}"
subtitle="${codename1.secondaryTitle}"
buildArgs="build.unitTest=1"
targetType="iphone"
certificate="${codename1.ios.debug.certificate}"
certPassword="${codename1.ios.debug.certificatePassword}"
provisioningProfile="${codename1.ios.debug.provision}"
appid="${codename1.ios.appid}"
automated="${automated}"
/>
</target>
<target name="test-for-android-device" depends="clean,copy-android-override,copy-libs,compile-test,clean-override">
<codeNameOne
jarFile="${dist.jar}"
displayName="${codename1.displayName}"
packageName = "${codename1.packageName}"
mainClassName = "${codename1.mainName}"
version="${codename1.version}"
icon="${codename1.icon}"
vendor="${codename1.vendor}"
subtitle="${codename1.secondaryTitle}"
buildArgs="build.unitTest=1"
targetType="android"
keystoreAlias="${codename1.android.keystoreAlias}"
keystore="${codename1.android.keystore}"
certPassword="${codename1.android.keystorePassword}"
automated="${automated}"
/>
</target>
After that, I sent an iOS build: it doesn't compile. So I tried to send an Android build. The generated apk, on a real device, produces an error because the /tests.dat file is absent. The exact error is: "Test data not found in the file, make sure the ant task was executed in full" (it's produced by DeviceRunner class at line 57). I added an empty tests.dat in /src, but it's not useful, because no test is runned.
I don't know what I have to do.
I need step-by-step instructions to test an app on a real device in the same way that I do in the Codename One Simulator. Thanks.
In the compile-test target which is the base target required we have this line:
<prepareTests classesDir="${build.classes.dir}" testClassesDir="${build.test.classes.dir}" seJar="JavaSE.jar" metaDataFile="${build.test.classes.dir}/tests.dat" />
This should generate a valid tests.dat file for the test directory which should get packaged into the build.

crawling all links of same domain in Nutch

Can anyone tel me how to crawl all other pages of same domain.
For example i'm feeding a website http://www.techcrunch.com/ in seed.txt.
Following property is added in nutch-site.xml
<property>
<name>db.ignore.internal.links</name>
<value>false</value>
<description>If true, when adding new links to a page, links from
the same host are ignored. This is an effective way to limit the
size of the link database, keeping only the highest quality
links.
</description>
</property>
And following is added in regex-urlfilter.txt
accept anything else
+.
Note: if i add http://www.tutorialspoint.com/ in seed.txt, I'm able to crawl all other pages but not techcrunch.com's pages though it has got many other pages too.
Please help..?
In nutch-default.xml set db.ignore.external.links to true and 'db.ignore.external.links.mode' to byDomain. Like this :
<property>
<name>db.ignore.external.links</name>
<value>true</value>
</property>
<property>
<name>db.ignore.external.links.mode</name>
<value>byDomain</value>
</property>
By default db.ignore.external.links.mode is set to byHost. Which means while crawing http://www.techcrunch.com/ the URL http://subdomain1.techcrunch.com will get treated as EXTERNAL and hence will be ignored. But you want sudomain1 pages to be crawled too - hence keep db.ignore.external.links.mode to byDomain
No work around required in regex-urlfilter.txt. Use regex-urlfilter.txt for some complex situation
I think you are using the wrong property, first use db.ignore.external.links in nutch-site.xml
<property>
<name>db.ignore.external.links</name>
<value>true</value>
<description>If true, outlinks leading from a page to external hosts
will be ignored. This will limit your crawl to the host on your seeds file.
</description>
</property>
b) Then you could also use a regex in regex-urlfilter.txt to limit the domains crawled to just techcrunch.
+^(http|https)://.*techcrunch.com/
However I think that your issue is that Nutch obeys the robots.txt file and in this case techcrunch has a Crawl-delay value of 3600!! see robots.txt. The default value of fetcher.max.crawl.delay is 30 seconds making Nutch dismiss all the pages from techcrunch.
From fetcher.max.crawl.delay in nutch-default
"If the Crawl-Delay in robots.txt is set to greater than this value (in
seconds) then the fetcher will skip this page, generating an error report.
If set to -1 the fetcher will never skip such pages and will wait the
amount of time retrieved from robots.txt Crawl-Delay, however long that
might be."
You may want to play with the fetcher.threads.fetch and fetcher.threads.per.queue values to speed up your crawl. You could also take a look at this and play with the Nutch code.. or you may even want to use a different approach to crawl sites with long crawl delays.
Hope this is useful to you.
Cheers!

Replicate Behavior of a Batch File in a Custom Action

I'm creating a wix installer at work, and I need to be able to replicate the behavior of this batch file in a custom action:
start /d "C:\Program Files (x86)\Remindex" INSTSRV.EXE RemindexNP
"C:\Program Files (x86)\Remindex\SRVANY.EXE"
I am trying to create a service using a normal windows application, which SRVANY.EXE can do. This batch file runs fine normally, but I can't seem to get a custom action to do the same thing. I have tried this:
<CustomAction Id="RunNP" FileKey="FILE_INSTALLFOLDER_INSTSRVEXE"
ExeCommand="RemindexNP [INSTALLFOLDER]SRVANY.EXE" Execute="commit" Return="ignore"/>
This custom action doesn't cause any errors that I can see in the log file, but I don't think instsrv.exe is accepting the parameters I'm passing in ExeCommand. I know that instsrv.exe and srvany.exe exist because I'm running the custom action before InstallFinalize.
Anyone know what's wrong with my custom action?
I would prefer not to include an actual batch file in my install folder, as it would have no reason to be there besides being run on install. I have tried including one in the installer, but I don't know how to reference the install directory. When I use %cd%, it just references the system folder for some reason.
I tried using ServiceInstall and ServiceControl elements, but the installer gets stuck on "starting services". Here is my component:
<Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}">
<File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe" KeyPath="yes"/>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\RemindexNP\Parameters">
<RegistryValue Id="rg_remNP1" Action="write" Name="AppDirectory" Value="[INSTALLFOLDER]" Type="string"/>
<RegistryValue Id="rg_remNP2" Action="write" Name="Application" Value="[INSTALLFOLDER]RemindexNP.exe" Type="string"/>
</RegistryKey>
<ServiceInstall DisplayName="RemindexNP" Id="srv_remNP" Name="RemindexNP" Start="auto" Type="shareProcess" ErrorControl="ignore"/>
<ServiceControl Id="srvc_remNP" Name="RemindexNP" Remove="both" Start="install" Stop="uninstall" Wait="no"/>
</Component>
And my log:
Action 17:15:08: StartServices. Starting services
Action start 17:15:08: StartServices.
StartServices: Service: Starting services
Action ended 17:15:08: StartServices. Return value 1.
Any suggestions would be greatly appreciated.
This is a trick question as you don't need a custom action. The srvany.exe acts as a service host and as such can be authored into your installer using the Directory, Component, File, ServiceInstall and (if desired) ServiceControl elements.

Resources