I have a build and release pipeline for Wordpress php files, but I only want to create a build for the files changed in source control. I am not using a Visual Studio Build task as this does not apply in case of php files I guess.
Here is how the pipeline is configured:
Currently under the build I am using publish artifacts only from $(Build.SourcesDirectory) and under the release pipeline I am copying those artifacts to the website using FTP upload.
Since the amount of files is larger than 10K,
I want it to only build files that have changed and publish those
instead of the whole directory again.
How do I achieve that within the build as the release will automatically pick files up based on the artifacts.
There isn’t the feature in VSTS that can just pick files up based on the previous artifacts.
You can refer to these ways to achieve it:
Create XML file that stores the last upload/publish information of each files (e.g. file name, date time, changeset/commit version).
Create a PowerShell script file that included the logical to compare files (get files metadata and compare with that XML file) and copy updated files to specific folder
Publish the files in that folder
Related
I an ASP.NET Core application I need to copy some fonts to the output directory. In my project I store these fonts in the directory ProjectFolder/Assets.
In the properties of each font I have set CopyToOutputDirectory to Always.
When Visual Studio build the project, the files are copied to the same directory where project.exe is built. This is the behavior I expect.
But when I build the project using VSTS, the files are copied to a sub-directory named Assets, this is one level below than the exe.
How can I make VSTS copy the files to the same folder than the exe (as Visual Studio does).
Thank you in advance.
With TFS2017update1 and above, VSTS, you could simply check Flatten Folders under Advanced option in Copy Files Task. The easiest solution for now.
This option in "Advanced" section of "Copy Files" step of your build definition.
This will flatten the folder structure and copy all files into the
specified target folder.
If this do not meet your requirement, you could try to use copy files step,take a look at this thread.
I am trying to populate a QTableview with some data. When developing under Qt Creator, data is read from build directory. Running the program each time, the QTableview keeps getting repopulated with previous data.
If I manually change the build directory each time before run, doesn't happen. But how do I solve the problem without manually changing the build directory every time I want a fresh run?
In your project directory there is a file name ProjectName.pro.user.
This file creating when you configure your project. it's XML file.
you can find this line on *.user files:
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/probook/Documents/Qt/testProject/Build/Windows/Debug</value>
This line define build directory address for debug. there is a same line for Release and Profile in that file.
You can also use Qt creator to define(customize) relative directory build:
goto Qt creator, Tools, Options..., Build & Run, General, Default build directory.
More info:
Qt Creator stores user-specific project settings in a .pro.user file. You can share these settings between several projects as a .pro.shared file. It has the same XML structure as a .pro.user file, but only contains the settings to share.
Based on comment, issue seems to be data which gets saved to build directory. And solution would be to remove it before running the application.
You can add Custom Process Step, either under Projects - Build Settings -
Build Steps, or under Projects - Run Settings - Deployment, and just delete the desired data files. Exact command depends on operating system.
An alternative might be to add a command line switch, something like --development-erase-saved-data, to the application itself, and erase the files (or just not read them, or whatever). Then add that command line switch to Projects - Run Settings - Run Steps - Command Line Arguments for desired build configurations.
Adding support for this in the application itself is easier to maintain, and is almost automatically cross-platform. However, it might be a feature you don't want in the application, though in that case you might only enable it for Debug builds (with #ifdef).
As a side note, saving data to executable directory is not a good idea these days. You might want to save it for example to location returned by
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
(See here for more info.)
We're using Visual Studio Team Services with Git as the source control system and I've configured a build which executes successfully online. Ideally I'd like to:
After building the site in VSO, precompile and dump the aspx and .dll files to the git repository
On the on-premises web server, pull from git and move to our staging site
The second part I can figure out on my own, but the documentation for VSTeam seems sketchy on how to dump the compiled sources to git. I've kept the default build configration almost the same as the default with the exception of a Powershell script which is supposed to create artifacts for the drop. Despite this, the drop.zip file create is empty.
The following is how my build definition is set up in VSO.
Instead of the PowerShell script, you'd be able to use the "Copy and Publish artefacts" and have it create a specific artefact with the specific bits you need:
This will automatically create a named build artefact which you can then use from Release Management as an input.
The PowerShell script was used in the XAML builds when used with the "Project Output | As Configured" option.
To create your "packaged" website, you need to add a couple of parameters to the MsBuild/Visual Studio Build step to instrict the compiler to package your website:
/p:DeployOnBuild=true /p:DeployTarget=Package
/p:SkipInvalidConfigurations=true /p:PackageAsSingleFile=false
/p:AspNetCompileMerge=true
Optionally you can configure your target directory as well using
/p:PackageLocation="$(Build.BinariesDirectory)\Published"
If you do this, you need to configure this directory as your copy root in the copy and publish task.
I did a quick look at the Power-Shell script, there are two issues with it:
It still use the variables like "$Env:TF_BUILD_SOURCESDIRECTORY" which does not exist in VSTS(VSO). See Variables for VSTS.
It copies the files from "BUILD_SOURCESDIRECTORY" folder to "BUILD_BINARIESDIRECTORY". But the "Publish Build Artifacts" step in your definition publish the files in "BUILD_ARTIFACTSTAGINGDIRECTORY" folder.
So if you want to use this script, you need to update the script to remove the "TF_" string in the variables and update the "Publish Build Artifacts" step to publish the files in "BUILD_BINARIESDIRECTORY" folder(Set Path to Publish to: $(Build.BinariesDirectory)).
However, if you want to copy and publish the website files, you can simply add one more argument in "MSBuild Arguments" section of "Visual Studio Build" step:
"/p:outdir=$(build.artifactstagingdirectory)"
Remove the Power-Shell script step and the other steps just keep default settings.
Or you can also change the settings of "Copy Files" steps to select the files/folders you'd like to copy.
I have a number of ASP.NET Web Form Websites (the one with no .csproj file), and I am trying to figure out how to best use NuGet packages with them. When using Visual Studio 2015, adding NuGet packages via the UI works correctly (there is a packages.config in the site root), and the build drops the binaries in the bin folder.
The problem is trying to build the project on TeamCity via MSBuild. For other projects, I can use NuGet.exe with the restore command (either against the csproj or the sln file), and the packages are correctly downloaded and included in the output. However, this doesn't work with the websites, and thus the compile fails due to missing files.
As a last resort, I could write a custom script/build step to manually copy the assemblies to the bin folder, but I'd like to avoid this. Am I missing something? Is there any way to use NuGet with websites outside of Visual Studio?
After some time, I have a workaround that gets me where I need to be, albeit not in the best way.
In newer versions of Visual Studio, when a binary dependency is added to a website via VS, it adds a (binaryfile).dll.refresh file to the bin folder alongside the binary file. The contents of the file is the relative path to the .dll via the packages folder for the solution. In addition, a packages.config file is added to the website.
The way to get it to build on a CI server is:
Ignore (.gitignore, .hgignore) the website's bin folder
Explicitly add the .refresh file(s) in the bin folder
Prior to the actual build, call NuGet restore, passing in the path to the website's packages.config and setting the PackagesDirectory (or SolutionDirectory) to the packages folder for the solution
Pre-Compile, MSBuild will open each refresh file, and copy the file from the location contained in the file.
It's not a great solution, because I now have to call NuGet restore multiple times (once for solution, once for each website), but it does work. I don't know how far back the .refresh file is supported, but it does work in 2015. I may make a change request in NuGet to allow for multiple solutions/packages.configs to be passed in via the command line.
Thanks,
Erick
What tool do you use to only zip up the source code of an open souce project or choose which files you want to include for packaging? I'm using Visual Studio 2008.
You can use a version control system like Subversion to do this. All the source files relevant to your project are checked in, and you can create a second working copy in another directory, check if it compiles (i.e. if the source is complete), clean it again, and zip it up minus the .svn directories.
In Visual Studio, use an add-on like AnkhSvn to make sure all files that are in your project are added to Subversion.
You can automate the svn update and zip with any kind of scripting language (msbuild, powershell, perl, python, etc...)
But then, you could also publish the Subversion repository url and let others use that instead of a .zip file!
Are you using a continuous integration process such as CruiseControl.NET? If so you can add a build step to zip up the entire working folder after a successful release build is done and any cleanup is performed, then even save it to an FTP somewhere if needed.
If not you could still do this in the build process from inside Visual Studio by editing the project file in the post build events. Both cases could be done using the MSBuild Community Tasks since there's a Zip task along with FTP and some others.
If you do an SVN Export instead of SVN Checkout, assuming you're using SVN, then the .svn folders won't be created so there shouldn't be any cleanup to perform before zipping up the folder since you'll have an exact copy of your trunk folder.
Ok, I have found 2 ways you can do this
http://www.codinghorror.com/blog/archives/000368.html
or
http://code.google.com/p/treetrim/