msbuild copy files - file

I am having trouble copying files with MSbuild and the error messages I'm getting seem to contradict each other (using TFS 2008 to do the build).
I currently having the following in my build script
<PropertyGroup>
<ReleaseRoot>$(DropLocation)\Latest\x86\Release</ReleaseRoot>
<WebRoot>$(ReleaseRoot)\_PublishedWebsites\Web</WebRoot>
<DBRoot>$(ReleaseRoot)\Database</DBRoot>
<TempHolingDir>$(ReleaseRoot)\temp)</TempHolingDir>
<WebConfig>$(WebRoot)\Web.config</WebConfig>
<DatabaseUpdate>$(DBRoot)\databaseupdate.exe</DatabaseUpdate>
</PropertyGroup>
<Copy SourceFiles="$(WebConfig);$(DatabaseUpdate)" DestinationFolder="$(TempHoldingDir)" ContinueOnError="false" />
When I run the build I get
error MSB3023: No destination
specified for Copy. Please supply
either "DestinationFiles" or
"DestinationDirectory".
I then change the DestinationFolder to DestinationDirectory and I got
error MSB4064: The
"DestinationDirectory" parameter is
not supported by the "Copy" task.
Verify the parameter exists on the
task, and it is a settable public
instance property. error MSB4063: The
"Copy" task could not be initialized
with its input parameters.
THese errors seem to contradict each other, what exactly am I missing here?

Restarting Visual Studio resolved this for me, so adding this as a potential solution for anyone else experiencing the same issue.

It's DestinationFolder according to Copy Task, looks like MSB3023 error text is wrong?

Its because you called your property TempHolingDir when your referred to it as TempHoldingDir.
Its all about the d.

Related

Android Manifest merger error in Codename One

In a bare bones project, I added these build hints:
android.gradleDep=compile 'com.erikagtierrez.multiple_media_picker:multiple-media-picker:1.0.5'
android.min_sdk_version=23
I would like to import the following Android library to make a CN1Lib (that requires at least Android SDK 23):
https://github.com/erikagtierrez/multiple-media-picker
To be short: I spent one day trying to import that, I also experimented with Android Studio and with suggestions found on Stack Overflow (trying to make a custom .aar), without success.
Could you help me to import that library? There is manifest merger error.
In fact, the issue reported by the build server is:
* What went wrong:
Execution failed for task ':processReleaseManifest'.
> Manifest merger failed : Attribute application#label value=(BareBones) from AndroidManifest.xml:15:17-42
is also present at [com.erikagtierrez.multiple_media_picker:multiple-media-picker:1.0.5] AndroidManifest.xml:23:9-41 value=(#string/app_name).
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:15:3-43:103 to override.
I also tried to add the build hint:
android.xapplication_attr=tools:replace="android:label"
as suggested by the previous error, without success.
In the last case, I get:
Merging result: ERROR
/tmp/build1659178556337293135xxx/Test/src/main/AndroidManifest.xml:15:3-43:103 Error:
tools:replace specified at line:15 for attribute android:label, but no new value specified
/tmp/build1659178556337293135xxx/Test/src/main/AndroidManifest.xml Error:
Validation failed, exiting
-- Merging decision tree log ---
The last full log is here: https://gist.github.com/jsfan3/dd6c23f86a2ac949f996910c8cece62b
Thank you
This is happening because our code things you injected android:label on your own and doesn't inject it to avoid collision...
Change the code to this:
android.xapplication_attr=tools:replace="android:label" android:label="App Name"

Display project version in ASP.NET Core 1.0.0 web application

None of what used to work in RC.x helps anymore.
I have tried these:
PlatformServices.Default.Application.ApplicationVersion;
typeof(Controller).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
Assembly.GetEntryAssembly().GetName().Version.ToString();
They all return 1.0.0.0 instead of 1.0.0-9 which should be after execution of the dotnet publish --version-suffix 9 having this in project.json: "version": "1.0.0-*"
Basically they give me "File version" from the attached picture instead of "Product version" which dotnet publish actually seems to change.
For version 1.x:
Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
For version 2.0.0 this attribute contains something ugly:
2.0.0 built by: dlab-DDVSOWINAGE041 so use this one:
typeof(RuntimeEnvironment).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
I would do it like this on ASP.NET Core 2.0+
var assemblyVersion = typeof(Startup).Assembly.GetName().Version.ToString();
In .Net Core 3.1 I show the version directly in my View using:
#GetType().Assembly.GetName().Version.ToString()
This shows the Assembly Version you have in your csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>2.2.2.2</FileVersion>
<Version>4.0.0-NetCoreRC</Version>
</PropertyGroup>
If you want to display the "other" FileVersion or "Informational" Version properties in the View add using System.Reflection:
using System.Reflection;
.... bunch of html and stuff
<footer class="main-footer">
<div class="float-right hidden-xs">
<b>Assembly Version</b> #(Assembly.GetEntryAssembly().GetName().Version)
<b>File Version</b> #(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version)
<b>Info Version</b> #(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion)
</div>
</footer>
Note that after adding the System.Reflection the original #GetType().Assembly.GetName().Version.ToString() line returns 0.0.0.0 and you need to use the #Assembly.GetEntryAssembly().GetName().Version
There's a blog post here
Edit: Make sure to follow proper naming conventions for the Version strings. In general, they need to lead with a number. If you don't, your app will build but when you try to use NuGet to add or restore packages you'll get an error like 'anythingGoesVersion' is not a valid version string. Or a more cryptic error: Missing required property 'Name'. Input files: C:\Users....csproj.'
more here:
This work for me too:
#Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion
It works with csproj file - either <Version>1.2.3.4, or <VersionPrefix>1.2.3</VersionPrefix>. However the <VersionSuffix> isn't recoganized as this doc says.
The answer by Michael G should have been the accepted one since it works as expected. Just citing the answer by Michael G above.
var version = GetType().Assembly.GetName().Version.ToString();
works fine. It gets the Package version set in the Package tab of project properties.
As an addition, if we need to get the Description we set in the same tab, this code would work. (core 3.1)
string desc = GetType().Assembly.GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
Just in case someone needs this.
Happy coding !!!

Getting StringIndexOutOfBoundsException when attempting to create a new Form in Codenameone

I am using Netbeans and updated to use the latest codenameone plugin. I am trying to follow the walkthrough tutorial at http://www.codenameone.com/blog/gui-builder-walkthru.html, but I keep on getting a StringIndexOutOfBoundsException when attempting to generate a new Form using the NewGuiBuilderWizardIterator. The following is the stacktrace that I'm seeing. Any and all help would be greatly appreciated!
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Relative path com\mycompany\myapp\MyApp.java
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Gui file C:\Users\joshua\Documents\NetBeansProjects\TestGui1\res\guibuilder\com\mycompany\myapp\MyApp.gui
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: Props C:\Users\joshua\Documents\NetBeansProjects\TestGui1\codenameone_settings.properties
SEVERE [com.codename1.actions.OpenGuiBuilderAction]: The GUI file doesn't exist!
WARNING [org.openide.filesystems.Ordering]: Found same position 100 for both Loaders/application/res/Actions/org-openide-actions-OpenAction.shadow and Loaders/application/res/Actions/sep-1.instance
WARNING [org.netbeans.modules.java.JavaTemplateAttributesProvider]: No classpath was found for folder: C:\Users\joshua\Documents\NetBeansProjects\TestGui1#b78894d2:1aed2d64
WARNING [org.openide.WizardDescriptor]
java.lang.StringIndexOutOfBoundsException: String index out of range: -4
at java.lang.String.substring(String.java:1919)
at com.codename1.NewGuiBuilderWizardIterator.instantiate(NewGuiBuilderWizardIterator.java:95)
at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1046)
at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:605)
at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:439)
at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:248)
at org.openide.loaders.TemplateWizardIteratorWrapper.instantiate(TemplateWizardIteratorWrapper.java:160)
at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1629)
at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1570)
at org.openide.WizardDescriptor.access$2300(WizardDescriptor.java:92)
[catch] at org.openide.WizardDescriptor$Listener$2$1.run(WizardDescriptor.java:2257)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
You need to select a package when you do this and not the top level project since the code won't recognize that situation and won't know where to place the GUI file.
Notice that since an XML GUI file is created in the background, refactoring after the fact won't work well so this isn't something we should generally fix.

Access to shared_path in deploy.rb

I try to set command map using shared_path like that:
SSHKit.config.command_map[:composer] = "php #{shared_path.join('composer.phar')}"
But the path is /var/www/xxx not using the path I set on :deploy_to deploy/staging.rb.
I guess this is because staging.rb is loaded after.
What the right way then?
I had the same issue and although I don't think I have found the best way. I have found a way.
My default :deploy_to in deploy.rb points to '/var/www/my_app'. And I have a development stage where the server uses the same path. But my production server uses '/home/httpd/something/else' so I put :deploy_to in production.rb expecting it to deploy to that path. And everything works except the composer command. The composer.phar file is downloaded to the correct shared path and the files are deployed correctly. But when composer runs it tries to find it in '/var/www/my_app/shared'.
What I did was instead of putting the SSHKit.config.command_map by it self in deploy.rb, put it in a task. Something like:
namespace :deploy do
before :starting, :map_composer_command do
on roles(:app) do |server|
SSHKit.config.command_map[:composer] = "#{shared_path.join("composer.phar")}"
end
end
...
end
It feels like SSHKit.config.command_map runs "to early" or something. This seems to help. It works for me at least. And I had the exact same issue.
Edit:
I got some help from an issue I posted on capistrano/composer.

How can I handle errors I get from the liquibase updateDatabase ant task

I'm currently working on some ant for applying liquibase changes to databases.
I'd like to be able to handle errors that I get in ant from the liquibase updateDatabase task. Here is what I have right now in my build file (bear in mind what I have now works fine I just need to be able to handle errors I might get from running the liquibase).
<target name="update_db" depends="prepare">
<taskdef resource="liquibasetasks.properties">
<classpath refid="classpath"/>
</taskdef>
<updateDatabase
changeLogFile="${db.changelog.file}"
driver="${database.driver}"
url="jdbc:mysql://localhost/${db.name}"
username="${user}"
password="${password}"
promptOnNonLocalDatabase="not local database"
dropFirst="false"
classpathref="classpath"
/>
</target>
Currently when I get an error I get something similar to this (from a situation I created to demonstrate):
BUILD FAILED
MYPATH\build.xml:15: The following error occurred while executing this line:
MYPATH\\build.xml:117: liquibase.exception.MigrationFailedException: Migration failed
for change set PATH/2.20.9/tables.xml::FFP-1384::AUSER:
Reason: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE
test.widget ADD full_screen BIT(1) DEFAULT 0: Duplicate column name 'full_screen'
.............. and a the wall of text continues
Ideally I would like to be able to get the return code (rather than this block of text) from liquibase into ant and then based on that do something such as :
<echo message="this failed because ${reason}"/>
but not limited to that.
Is there some way for me to obtain the return code from liquibase? My best guess is that similar to the ant exec task, by default the return code is ignored and I'm hoping there is some way for me to get at it. Any suggestions welcome.
edit: Vaguely similar question https://stackoverflow.com/questions/17856564/liquibase-3-0-2-logging-to-error-console
The ant contrib trycatch task has enabled me to handle the error, which turned out to be a suitable fix since the stack trace is actually useful to see anyway.
http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html
<trycatch property="foo" reference="bar">
<try>
<fail>Tada!</fail>
</try>
<catch>
<echo>In <catch>.</echo>
</catch>
<finally>
<echo>In <finally>.</echo>
</finally>
</trycatch>
You need to download the ant contrib jar and if you don't want to place it in your ANT_HOME then you can use
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="PATH TO JAR"/>
</classpath>
</taskdef>

Resources