ExtJs Adding additional files to build - extjs

How to use 'app.json' to add additional files to the production build when I use the following command
sencha app build
For example, I have some static HTML pages updated regularly located in the root directory, so I want those files to be copied to the production directory

You can use the build.xml file located in the project's root directroy. Add the following to the main <project> block:
<target name="-after-build">
<copy todir="${build.dir}/myfolder">
<fileset dir="${app.dir}/myfolder" />
</copy>
<copy todir="${build.dir}">
<fileset dir="${app.dir}">
<include name="favicon.ico"/>
</fileset>
</copy>
</target>
The first example copies an entire folder, the second copies a file from the project root folder to the build folder.

Related

How to flatten Nuget package contentFiles?

Nuget package issues - buildAction, copyToOutput, flatten are ignored
Package project (ThisProject.vbproj)- .Net Standard Library 2.0, .nuspec file:
<references>
<reference file="ThisProject.dll"></reference>
<reference file="First.dll"></reference>
<reference file="Second.dll"></reference>
<reference file="...."></reference>
</references>
<contentFiles>
<files include="any/any/*" buildAction="Content" copyToOutput="true" flatten="true" />
</contentFiles>
</metadata>
<files>
<file src="contentFiles\any\any\First.dll" target="lib\any\any\First.dll"></file>
<file src="contentFiles\any\any\Second.dll" target="lib\any\any\Second.dll"></file>
<file src="contentFiles\any\any\....dll" target="lib\any\any\.....dll"></file>
</files>
When importing in .net ClickOnce Framework 4.6.1 Project, the contentFiles are still in the subfolders (flatten is ignored), Build Action and CopyToOutputDirectory are the defaults (buildAction,copyToOutput are ignored)
Read all the documentation I could find e.g.
https://learn.microsoft.com/en-us/nuget/reference/nuspec
What am I doing wrong?
I think you have some misunderstanding about this part.
First, contentFiles works for new-sdk projects(Net Core and Net Standard) with PackageReference nuget management format rather than Net Framework project with packages.config nuget management format.
And contentFiles works for content files rather than lib folder. So you should not pack these dll files on target="lib\any\any\.....dll". You should pack them into contentFiles folder.
Use this:
<contentFiles>
<files include="any/any/*" buildAction="Content" copyToOutput="true" flatten="true" />
</contentFiles>
<files>
<file src="xxx\First.dll(the physical, relative path of the dll on your project folder)" target="contentFiles\any\any\First.dll"></file>
<file src="xxx\Second.dll(the physical, relative path of the dll on your project folder)" target="contentFiles\any\any\Second.dll"></file>
<file src="xxx\....dll(the physical, relative path of the dll on your project folder)" target="contntFiles\any\any\.....dll"></file>
<files>
Then, you should install this nuget package on a Net Core project.
When you finish it, repack the project with nuget pack command, then, before you install the new one, clean the nuget caches first to remove the old previous version. Then, install the new version on a Net Core project and you can see the effect like this:
======================================================================
If you still want to have this function on a Net Framework project, you should pack these files on content node rather than contentFiles.
And you only need to add two lines:
<contentFiles>
<files include="any/any/*" buildAction="Content" copyToOutput="true" flatten="true" />
</contentFiles>
<files>
<file src="xxx\First.dll(the physical, relative path of the dll on your project folder)" target="contentFiles\any\any\First.dll"></file>
<file src="xxx\Second.dll(the physical, relative path of the dll on your project folder)" target="contentFiles\any\any\Second.dll"></file>
<file src="xxx\....dll(the physical, relative path of the dll on your project folder)" target="contntFiles\any\any\.....dll"></file>
<file src="xxx\First.dll(the physical, relative path of the dll on your project folder)" target="content"></file>
<file src="xxx\Second.dll(the physical, relative path of the dll on your project folder)" target="content"></file>
..........
<files>
But these simply cannot change the attributes of the imported file. And for net framework project, changing the property of the files cannot be done on xxx.nuspec file.
You should use <packages_id>.props or targets file.
1) create a file called <packages_id>.props under the build folder on the Solution Explorer, if your nuget package is named as ThisProject.1.0.0.nupkg, you should name it as ThisProject.props so that it will work.
This is mine:
2) add these on the props file:
<Project>
<ItemGroup>
<Content Include="First.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Second.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......
</ItemGroup>
</Project>
3) add a line on nuspec file to include the props file into the nupkg.
<file src="build\xxx.props(the physical, relative path of the file on your project folder)" target="build"></file>
4) then repack the nuget package, clean the nuget caches, then install this new one on the Net Framework project with packages.config.
Note: although the Properties window of the imported content file on the solution explorer does not show the changed value and still shows the old one, the files are already copied into the output folder of the project. And it is an UI display issue on Solution Explorer and the changed values are already be used and work well. So you do not have to care much about that.

.net core / standard csproj how to trigger build when external file dependency changes

Trying to trigger a build of a .net standard/core csproj when an external file changes. The file is in the the $(USERPROFILE)\Documents directory.
Have tried Targets with BeforeTargets equal to PrepareForBuild, PreBuildEvent but none work.
<Project Sdk="Microsoft.NET.Sdk" Project="Sdk.props">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
</PropertyGroup>
<Target Name="PrepareForBuild2" BeforeTargets="PrepareForBuild">
<Exec Command="echo PrepareForBuild2" />
</Target>
</Project>
Found solution - use UpToDateCheckInput
<ItemGroup>
<UpToDateCheckInput Include="$(USERPROFILE)\Documents\MyFile.txt" />
</ItemGroup>

Using a batch file to build dlls and update references in Visual Studio 2013

For the gurus out there in batch file writing and Visual Studio (most significantly Visual Studio 2013), I would like to know if it is possible to do the following:
I have a series of projects part of a solution, many of which are dependent on the dll's generated by other projects (in a waterfall fashion really). I would like to know if it is possible to write a batch file to build all projects to generate the corresponding dll's, and then update their references to the newly assembled dll's (also with the batch file).
Is this even possible? I would like avoid using extensions like NuGet or any other software.
You pick the right language/tool to do builds. msbuild is the tool (and kind of the language) that you write this kind of stuff. they are called build-scripts. they are NOT bat scripts. do not use .bat scripts. that's what people did 20 years ago.
Below is a basic msbuild script file. It will
Build the .sln
copy the files of one of the csproj's (usually the GUI csproj) to a folder
zip the files into a zip file
You would put this in a file called "MyBuildScript.proj" (or MyBuildScript.msbuild)
After you do that, you will execute the file with msbuild.exe
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" /target:AllTargetsWrapped "MyBuildScript.proj" /p:Configuration=Debug;FavoriteFood=Popeyes /l:FileLogger,Microsoft.Build.Engine;logfile=MyBuildScript.proj.Release.log
(MyBuildScript.proj)
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
<PropertyGroup>
<!-- Get this project from http://msbuildextensionpack.codeplex.com/releases/view/105659 -->
<MSBuildExtensionPackFoundPath Condition="Exists('$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks')">$(MSBuildExtensionsPath64)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</MSBuildExtensionPackFoundPath>
<MSBuildExtensionPackFoundPath Condition="Exists('$(MSBuildExtensionsPath32)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks')">$(MSBuildExtensionsPath32)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</MSBuildExtensionPackFoundPath>
<MSBuildExtensionPackFoundPath Condition="Exists('$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks')">$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks</MSBuildExtensionPackFoundPath>
<MSBuildExtensionPackFoundPath Condition="$(MSBuildExtensionPackFoundPath)==''">CouldNotFindBaseDirectoryCheckForInstalledProduct\MSBuild.ExtensionPack.tasks</MSBuildExtensionPackFoundPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionPackFoundPath)"/>
<PropertyGroup>
<!-- Always declare some kind of "base directory" and then work off of that in the majority of cases -->
<WorkingCheckout>.</WorkingCheckout>
<WorkingDir>.</WorkingDir>
<ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder>
<ZipArtifactDestinationFolder>$(WorkingDir)\ZZZZipArtifacts</ZipArtifactDestinationFolder>
</PropertyGroup>
<Target Name="AllTargetsWrapped">
<CallTarget Targets="CleanArtifactFolder" />
<CallTarget Targets="BuildItUp" />
<CallTarget Targets="CopyFilesToArtifactFolder" />
<CallTarget Targets="ZipItUp" />
</Target>
<Target Name="BuildItUp" >
<MSBuild Projects="$(WorkingCheckout)\Solution1.sln" Targets="Build" Properties="Configuration=$(Configuration)">
<Output TaskParameter="TargetOutputs" ItemName="TargetOutputsItemName"/>
</MSBuild>
<Message Text="BuildItUp completed" />
</Target>
<Target Name="CleanArtifactFolder">
<RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/>
<MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/>
<RemoveDir Directories="$(ZipArtifactDestinationFolder)" Condition="Exists($(ZipArtifactDestinationFolder))"/>
<MakeDir Directories="$(ZipArtifactDestinationFolder)" Condition="!Exists($(ZipArtifactDestinationFolder))"/>
<Message Text="Cleaning done" />
</Target>
<Target Name="CopyFilesToArtifactFolder">
<ItemGroup>
<MyExcludeFiles Include="$(WorkingDir)\**\*.doesnotexist" />
</ItemGroup>
<ItemGroup>
<MyIncludeFiles Include="$(WorkingDir)\CsProjectOne\bin\$(Configuration)\**\*.*" Exclude="#(MyExcludeFiles)"/>
</ItemGroup>
<Copy
SourceFiles="#(MyIncludeFiles)"
DestinationFiles="#(MyIncludeFiles->'$(ArtifactDestinationFolder)\%(Filename)%(Extension)')"
/> <!-- %(RecursiveDir) -->
</Target>
<Target Name="ZipItUp">
<ItemGroup>
<NonConfigFilesExcludeFiles Include="$(ArtifactDestinationFolder)\**\*.doesnotexist" />
</ItemGroup>
<ItemGroup>
<NonConfigFilesIncludeFiles Include="$(ArtifactDestinationFolder)\**\*" Exclude="#(NonConfigFilesExcludeFiles)"/>
</ItemGroup>
<!-- Create a zip file based on the FilesToZip collection -->
<MSBuild.ExtensionPack.Compression.Zip TaskAction="Create" CompressFiles="#(NonConfigFilesIncludeFiles)" RemoveRoot="$(ArtifactDestinationFolder)" ZipFileName="$(ZipArtifactDestinationFolder)\MyOutputFile.zip"/>
<!-- -->
</Target>
</Project>
That is how you write build-logic. There are other build tools out there, but this is the default dotNet one.
Do NOT write crappy, hard to maintain .bat files.
Use the correct tool for the job.
PS "msbuildextensionpack" is an example of extensions for msbuild. there are MANY MANY helpful extensions for msbuild. 99% of the time, somebody has written a msbuild extension to help do what you need to do.
Need to send a file to an ftp client destination? Somebody already wrote a task.
Need to manipulate some .xml file? Somebody already wrote a task.
Need to zip a file (like in this example). Somebody already wrote a task.
Need to do........anything mainstream........ Somebody already wrote a task.

nuget pack content files only

I'd like to create a nuget package (from some c# project), but I don't want to embed the generated dll, but just some static files instead.
I added a tag at the end of my nuspec file, but nuget pack command continues to embed the project.dll in the package.
The thing is I don't want this dll to be published.
Is there any way to do that?
Thanks,
RĂ©gis
Yes. You can create a .nuspec file that simply references the content files.
You must use nuget pack MyPackage.nuspec
Don't pack the .csproj file as that causes NuGet to include the built assembly.
See http://docs.nuget.org/create/nuspec reference for more info.
To package a file as content, you must use target=content when listing the file in your .nuspec document.
To create a 'content only' nuget package, you must use a <files> node to list the files.
A <files> node must be a sibling of the <metadata> node.
A <file> node must be a child of a <files> node.
To include a file as content, set the target attribute in a <file> node to 'content'.
Example:
<files>
<file src="{filePath}" target="content"/>
</files>
As previously mentioned, you must then pack the .nuspec file rather than a .csproj file:
nuget pack *.nuspec
I found the target=content trick here:
https://learn.microsoft.com/en-us/nuget/reference/nuspec#including-content-files
For contentFiles i use this way in the nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>DummyNuget</id>
<version>1.0.1-alpha</version>
<title>DummyNuget</title>
<authors>DummyNuget</authors>
<owners>DummyNuget</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>DummyNuget</description>
<releaseNotes></releaseNotes>
<copyright>2019</copyright>
<tags></tags>
<contentFiles>
<files include="**\*.*" buildAction="Content" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="<path to files>\*.*" target="contentFiles\any\any" />
</files>
</package>
files to put the local files in the nuget package then contentFiles in the metadata to put all the files in the project as content copy to output

How can we copy the jar file created in net beans project to some folder immediately after it stops building?

I wish to copy the executable jar file of a project immediately after its building completes to another folder location.
I do have a batch file to do that but, I wish to automate that in such a way that it is executed as and when the build finishes ..... !
How can I do it ?
Please help!
I guess by editing the Build.xml file one can try copying the file automatically to a desired location.
This is the Build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="testBuildXml" default="default" basedir=".">
<description>Builds, tests, and runs the project testBuildXml.</description>
<import file="nbproject/build-impl.xml"/>
<property name="src" value="<path-to-your-batch-file>"/>
<target name="**-post-jar**">
<exec dir="${src}" executable="cmd.exe">
<arg line="/c copy.bat"/>
</exec>
</target>
</project>
"-post-jar" allows the batch to execute only after the jar building process is complete.
For further information you may check out this web page.

Resources