Setup teamcity to pull .asp/html files from TFS - asp-classic

Currently, we have several build configurations for .net projects with Team foundation as the version control. Trying to create a build configuration for a classic asp site under TFS (no files that need to be compiled or .dlls). Not sure how to go about the steps in creating the build configuration (General Settings, Version Control Settings, Build Steps, etc..).
Using TeamCity Professional 7.0.3.

This is an example that I'm using:
General Settings:
The artifact path needs to map to a folder in your vcs. e.g.
%Sourcedirectory%/**
In VCS Settings, you should specify a branch to get e.g. +:master
In Checkout rules, you can limit what to get
+:Mycheckoutpath
Use a command line build step to copy files
(robocopy %SourceDirectory% %DestinationDirectory% /MIR /NP /NDL) ^& IF %%ERRORLEVEL%% LEQ 4 exit /B 0
The variables in "%" are defined as parameters.
Use the ^& IF %%ERRORLEVEL%% LEQ 4 exit /B 0 to make sure to catch returncode 2 to be accepted (this is file overwritten)

Related

Dockerfile COPY ${source:-obj/Docker/publish} not finding the correct source after upgrade to 3.1

I am using Jenkins to build and deploy a .Net Core microservice application. For each microservice, I am building a docker container. My dockerfile has the following in it:
ARG source
COPY ${source:-obj/Docker/publish} .
Prior to upgrading from .Net Core 2.2 to 3.1, this worked. After the upgrade, when I try to deploy, I am getting the following error:
COPY failed: stat /var/lib/docker/tmp/docker-builder609391151/obj/Docker/publish: no such file or directory
script returned exit code 1
From what I've read, it looks like .Net Core 2.2 compiled into the /obj/Docker/publish directory, but .Net Core 3.1 compiles into the /bin/Release/netcoreapp3.1 directory, however the source is still pointing to /obj/Docker/publish. I'm trying to figure out where the source arguement is defined, and how I should change this.
Update:
I decided to leave the source out entirely and hard-code the build path. I changed the copy line to
COPY /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/obj/Release/netcoreapp3.1 .
I'm still getting an error when I try to build the docker container that says
COPY failed: stat /var/lib/docker/tmp/docker-builder356954794/var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/obj/Release/netcoreapp3.1: no such file or directory
script returned exit code 1
I'm not sure where the "/var/lib/docker/tmp/docker-builder356954794" is coming from, or why it is appending it to the front of my path, but it doesn't exist.
Still not sure how to get around this.
Some debugging suggestions in no certain order.
Default Value
${source:-obj/Docker/publish} is bash syntax that evaluates to the value of the variable source if it was defined, or obj/Docker/publish if it was not.
I'm trying to figure out where the source argument is defined, and how I should change this.
If you can't find anything that defines it to another value, it just means that the default value obj/Docker/publish was being used.
Publish directory
3.1 still uses the publish directory, but it will be at bin/Release/netcoreapp3.1/publish. Use a RUN find -type d -iname publish to find the publish directories in your container.
Dont use the full path, it will change every build. See the tmp/docker-builder356954794 in the path?
The COPY command uses relative files, based on the path in your machine (outside the docker container). So use a path that's relative to where the context directory (or Dockerfile) is. If the dockerfile is at /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/Dockerfile and the publish directory on your machine is at /var/lib/jenkins/jobs/fusion-core/branches/master/workspace/src/CustomerAPI/bin/Release/netcoreapp3.1/publish, then use a COPY command like this:
COPY bin/Release/netcoreapp3.1/publish .
Funny paths
I'm not sure where the "/var/lib/docker/tmp/docker-builder356954794" is coming from
Containers need to share files from one directory (in your host) to another (in your container). Depending on the container technology, it uses one or more file systems or file directories.
One of those is /var/lib/docker/tmp/...

dotnet publish output folder?

The dotnet publish command published into the projects bin/netcoreapp2.2/Debug/publish folder. Where netcoreapp2.2 presumably changes with the dotnet version and Debug changes with whatever configuration the -c parameter specifies.
For CI/CD purposes this is clearly undesirable. Alternatively one can pass -o to pass an explicit output path, but again, in a CI/CI environment this path should be inside the project folder structure, e.g. something like:
dotnet publish -o publish
But, because the publish command globs up all files, it picks up previous publish attempts and recursively stores them. This can be mitigated by either cleaning the publish folder explicitly, and/or adding a to the csproj for the project but now there is a dependency between the build script and the csproj: if the publish path is changed in the build scripts for any reason without a corresponding csproj update things break.
So, the least fragile option seems to be to use the default output path as thats automatically excluded from globbing, but how to remove the version & configuration sensitivity? Is there a particularly safe way to get dotnet to tell my CI/CD environment what its output path for build / publish is?
IMP: I do not have enough so reputation to add comment
refer : dotnet publish
you could use relative path with -o option and you may end up avoiding folder name with run-time, platform identification explicitly.
or why do not you consider using build command with publish profile where you can specify explicit path. but generally relative path is less error prone.
Hope this may help you !

Visual Studio Team Services dotnet publish

My build completes with no errors, but it creates a randomly named zip file (s.zip) for the release step.
After the release step, I end up with that s.zip in inetpub/wwwroot/admin-tool/ folder. I'm almost there, but I want it to unzip and dump all the contents in here. This should be automatic, shouldn't it?
My dotnet publish looks like this:
and cause this to run, which is how I get the s.zip:
C:\Program Files\dotnet\dotnet.exe publish C:\agent\_work\3\s\Angular.AdminTool.csproj -c release --output C:\agent\_work\3\a\s
If I try to edit the -o argument and make it -o $(Build.ArtifactStagingDirectory)/admin-tool I will just end up with C:\agent\_work\3\a\admin-tool\s.zip
Is getting the name of my zip to be the same as the name of my web-site (admin-tool) the key to getting the zip to automatically extract in the release step?
In case it help others, I used the simple command line tools rather than the pre-canned "dotnet core" ones:
and for the Archive files task, be sure to include a hard-coded name for the zip to be used in the build process:
And for the release, in the "Deploy IIS App" task, be sure to include the full path for the zip file:
I also ran into this issue but solved it another way.
In my case I have a single project to build and deploy.
The $(Parameters.RestoreBuildProjects) value is set to a single project
MyProjectFolder/MyProject.csproj.
In the .Net Core Publish task, this value is used in the Path to Project(s) field.
Then I tick both the boxes for
I saved and queued this pipeline.
The zip file created seems to be derived from the name of the folder
so I ended up with a zip file in the artifact staging directory with the name of the project. Then the Publish Artifact task placed this zip file into the Artifact that is named in that task.

pubxml web publish tool Event Lifecycle

I am using the Web publishing tool from Visual Studio 2012 to publish to File System. I learned that I can open my *.pubxml in the Properties folder to do more advanced things.
What I want to do is run a command line application at the end of the publishing task.
I would usually do it in a Custom Target and execute it after one of the build in Events like this.
<Target Name="CustomAfterPublish" AfterTargets="GatherAllFilesToPublish">
</Target>
The problem is that GatherAllFilesToPublish is way to early because I want to execute it at the very last, after publishing was done.
Is there a list or does someone know the build in events and there order in which they are fired? Basically the Event Lifecycle of a FileSystem web publish.
Or how can I fire a Target manually at the very end?
I tried following without success:
<Target Name="Msg" AfterTargets="PipelineDeployPhase;MSDeployPublish;Package">
And also every each of them individually.
So what's the very last hook of the publishing lifecycle?
---> Edited
I added already tracing. The problem is that the files were copied to a temp path and after that all files are deleted. So copying to the destination will not work after "GatherAllFilesToPublish"See my trace from the command line window here...
1>------ Build started: Project: Dependency of a project: Release Any CPU ------
2>------ Build started: Project: Dependency of another project, Configuration: Release Any CPU ------
3>------ Build started: Project: Web, Configuration: Release Any CPU ------
4>------ Publish started: Project: Web, Configuration: Release Any CPU ------
4>Transformed Web.config using C:\...\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
4>Copying all files to temporary location below for package/publish:
4>obj\Release\Package\PackageTmp.
**<------------- Here is the place where my excutable is called ---------------------------------**
4>Deleting existing files...
4>Publishing folder /...
4>Publishing folder App_Browsers...
4>Publishing folder App_Themes...
4>Publishing folder bin...
4>Site was published successfully file:///C:/Test
4>
========== Build: 3 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Thanks for any help.
As far as I can tell GatherAllFilesToPublish is the last event available. However, depending on your requirements you may still be able to use this event.
Instead of performing operations on files in the final publish location, you can target the intermediate files written to the location below (where ProjectDir is the folder of your project obviously)
/ProjectDir/obj/Release/Package/PackageTmp/
It seems that Visual Studio does a straight copy of all files in this directory. So, when hooking into GatherAllFilesToPublish you should be able to make any changes to the files in this directory and they will be reflected in the final publish location.
Related Information
If you'd like to verify that GatherAllFilesToPublish is truly the last event you can do this yourself by enabling Diagnostic build output.
Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild
project build output verbosity -> Diagnostic
Build the project and search for Done building target "GatherAllFilesToPublish", for me this was the last trigger before it started copying the files to the publish location.
I had the same problem. Your solution
Coping first to the temp directory and let web publish picking up the
coping for publishing
was helpful.
I just want to share for other people how it can be done:
<Target Name="CopyConfigForPublish" AfterTargets="CopyAllFilesToSingleFolderForPackage" Condition="exists('$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config')">
<Copy SourceFiles="$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config" DestinationFolder="$(WPPAllFilesInSingleFolder)" />
</Target>
I had a similar issue.
As far as i could check, "GatherAllFilesToPublish" is the last target you can deal with. You can use it doing an AfterTargets.
And use this >
$(MSBuildProjectDirectory)\obj\Release\Package\PackageTmp
To manipulate anything there.
What I did was creating an .bat file to do the dirty work.
You can find out which one is the variable that stores the relative part of the path (\obj\Release\Package\PackageTmp) and use it on more refined way.

where does qtcreator with cmake store run and build settings, and how to set via script?

In my usage at least, I sometimes delete my CMake build folder and create a new one, or have multiple build folders (one per computer) but only one source folder (nfs mount).
From what I can tell, QT Creator saves settings into CMakeLists.txt.user inside the source tree, and some others settings into the 'project.cbp' file in the build folder. If I set settings from the GUI, they are lost after wipe/create build folder. Fair enough, but I'd like to use a script to set them up again when a new build is made.
So, how do I:
a) make QT Creator write the CMakeLists.txt.user folder somewhere other than the source tree so that machine-specific settings are kept (e.g. debug on the development computer, release on the test computer) ?
b) read/write the build and run settings from QT Creator project, such as debug arguments for each executable and extra build commands (e.g. -j8) ?
Then I would do something like "execute_process( ... )" in CMakeLists.txt to set some debug and build arguments for the QT Creator project.
Ah, actually the command args, build settings, and related items are set in the CMakeLists.txt.user from QTCreator...
for example:
<valuemap key="ProjectExplorer.Target.RunConfiguration.1" type="QVariantMap">
<value key="CMakeProjectManager.BaseEnvironmentBase" type="int">2</value>
<value key="CMakeProjectManager.CMakeRunConfiguation.Title" type="QString">matching_test</value>
<value key="CMakeProjectManager.CMakeRunConfiguration.Arguments" type="QString">camera.pklogitech.yml 0 .</value>
so the args that are used are " camera.pklogitech.yml 0 . " for this binary's entry...
So I guess a script could be made to go in and set those values by default... too bad QT Creator doesn't provide a nicer interface to import them.

Resources