Precompiling and Deploying website from Visual Studio Team Services - asp.net

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.

Related

Build directory for Qt Creator IDE

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.)

How to create MSdeploy Package using MSBuild for all files in this project folder

I'm trying to create a web deploy package using msbuild through command line. I have been searching all over and found the following command
msbuild myproject.csproj /t:package
Though it works for me but it gives me only what visual studio gives us back when we create web deploy package through Packge/Publish Web tab with "only files needed to run this application" option selected from the drop down menu. But I want my web deploy package to look exactly the same as what I get when I select "All files in this project folder" option from the drop down menu. I have gone through links like this http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx.
But I wonder that do I really need to customize my .csproj file (the way its been described in that post) since all I want, is a command line (apparently more elaborate than the one I mentioned above) for msbuild that can imitate the "All files in this project folder" option that populates the "bin folder of web deploy package" with all the .dlls that are there in the original bin folder of my project and generate me a more comprehensive package.
In your commandline simply add /p:FilesToIncludeForPublish=AllFilesInProjectFolder to your msbuild invocation. While you're at it, you may also want to pass in a specific configuration to build /p:Configuration=Release
So:
msbuild myproject.csproj /t:package /p:FilesToIncludeForPublish=AllFilesInProjectFolder /p:Configuration=Release
Tip: Many of these settings are stored in your project file. Open up your file in Notepad and compare the changes made when you have changed some settings. Any item that's in a <propertygroup> can usually be passed along through the commandline as well using the /p: parameter.

How to preserve existing files and folders on site update?

I'm using Microsoft Web Deploy to publish and update my site. (script is generated with Visual Studio). This tool removes auto-generated files and folders on update, as they are not included into install package. How to make it keep these files?
The Web Deploy command line tool has two switches that may be useful: -skip and -enableRule:DoNotDeleteRule. For information on -skip, see Web Deploy Operation Settings, and for DoNotDeleteRule, see Web Deploy Rules.
In Visual Studio, you may be able to tweak the deploy.cmd file to use these to achieve what you want. For more information, see How to: Install a Deployment Package Using the deploy.cmd File.
Having to edit the deploy.cmd files each time you generate them is a pain. I am using VS2017 and found I can set an environment variable on the server and deploy.cmd will use it. The deploy readme file says it:
Alternatively, you can specify additional flags by setting the
"_MsDeployAdditionalFlags" environment variable. These settings are
used by this batch file.
So on the server I created the environment variable:
_MsDeployAdditionalFlags=-enableRule:DoNotDeleteRule
And that did it. It now adds the rule each deploy on the server.

use dotfuscator after build time

how can I use dotfuscator for my dlls in web application after build time so when I publish my website it will contain the encrepted dlls instead of the old ones?
Use Post-build event command in VS 2008.
Right click on your csproject, choose properties, go to build event, then inside the post build event command line, type in the following batch command:
dotobfuscator command line, and
the command to copy the files to the website (i.e, copy %encrypteddll% %destination%) .
The copy command should be something like this:
copy "D:\EncriptionFolder\BusinessEntitesLayer.dll" "D:\wefaq\SocialProject\SocialProject\bin\BusinessEntitesLayer.dll"
Or alternatively, you can use NANT or other build tools to automate your build steps.

Tool for packaging a .NET project

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/

Resources