How does "Publish" in Visual Studio Work? - visual-studio

I am wondering how does Publish in Visual Studio work, the question is:
Does the Publish in VS gets the code in the control-version to be built and published or does it get the code in local-machine to be built and published?

How does Publish in Visual Studio Work?
In simple terms, Publishing creates the set of files that are needed to run your application, and you can deploy the files by copying them to a target machine.
See How Web Publishing In Visual Studio Works for some more details.
Now, we need to figure out the question "Does the Publish in VS gets the code in the control-version to be built and published or does it get the code in local-machine to be built and published?".
To figure out the question, we need to change the "MSBuild project build output verbosity" to "Detailed". Do this by Tools -> Options...->Projects and Solutions->Build and Run. Set the MSBuild project build output verbosity level to Detailed. Then publish our project and check the log on the Output window, you will find Visual Studio copy the files from obj folder instead of the source code in the project file when you publishing project:
So, Publish code should come from local-machine to be built and published.

Related

Visual Studio 2013 and TFS Build 2015: Devenv.exe unable to produce MSI file

We are in the process of upgrading our TFS 2013 server to TFS 2015. In that regard I have run into an issue when trying to perform an application build on a build agent with the new version, using our XAML template build script (which was created in TFS 2013).
Most of our solutions use the above-mentioned template when we build them. The solutions (sadly, still) use setup projects (.vdproj) to generate an MSI package for the application. To build the setup project, and produce an MSI, for a given application; we call the devenv.exe (in our case, it points to Visual Studio 2013) in our template build script:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe /Build "Release|Any CPU" "d:\<path_to_solution>\solution.sln" /Out c:\temp\out.log
However, on our new build agent no MSI is produced, and calling devenv.exe yields neither any output, nor any error messages. If I try to call devenv.com, however, it starts building, but still no MSI is being produced.
When things start to build using devenv.com It seems like it is completely disregarding the setup project (I have checked the build configurations, and the setup project is checked for build on the "Release|Any CPU" configuration).
I have looked at build logs, build process activity logs, and I have also tried to perform the steps manually on the build agent, but I haven't been able to find anything that could point me in the direction as to what might be causing the issue.
Does anyone have an idea what could be the reason for this? Could it be an issue with TFS Build 2015? The only difference between the old setup, and the new - as far as I can tell - is the following:
VS 2013 was installed on C: rather than D: on the new build agent, i.e. the path to devenv would be different, but that should not matter as long as the build script is looking in the right place, and finds it...
We use a different drop location than what we used for the old setup
Appreciate any help and suggestions I can get.
Problem solved, and everything is now building successfully. I did not do a good enough job of looking at the diff between the setup we had on the build agent we used for TFS Build 2013 vs. the one we set up for TFS Build 2015.
Firstly, to be able to build setup projects in VS 2013, one needs to install the Visual Studio 2013 Installer Projects extension on the build agent.
However, there are some bugs with this extension that often causes building setup projects to yield the following error message: "An error occurred while validating. HRESULT = '8000000A'". This error can be fixed by modifying the registry, as described in this SO post.
Building the setup projects using devenv.exe, however, still doesn't work. I have not been able to figure out why, yet.
Use the Vnext build in TFS 2015 to build .vdproj. You just need to add one additional build step i.e "command line" then call devenv.com to build.
Such that,
tool :
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com
arguments :
HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj /build release
This will help you.

Configure Teamcity to build a published website with Visual Studio

How does one configure the teamcity build process to produce the same compilation result as if I told Visual Studio to publish a website from Visual Studio?
basically, I need teamcity to build the website with a publishable package...then publish the package as an artifact, which I can then deploy on AWS using command line commands.
Is it possible? What are the command line MSBuild parameters necessary to get Visual Studio to spit out what I am looking for, and what would I need to match in the build output in order to publish the package? Currently, the website is too big for me to publish everything as an artifact, so I'm having trouble figuring out what to match for artifact publishing.
You need to build target WebPublish - that's what VS does when you select web project and publish it from context menu.

How to download build files from Visual Studio Online?

I am a newbie in Visual Studio and have my projects deployed on Visual Studio Online. How can I download the successful build files from Visual Studio Online to my machine. Because as far as I know, after successful completion of the build, we can only download logs as zip file.
I know it is a bit late to answer this question, but in case someone still looking for solution, I used this one:
When creating build definition, in "Build Defaults" pane selected "Copy build output to the following Source Control folder".
In textbox I typed "$/[Your project root]/Drops" where [Your project root] is the root name of your project base.
After that I can build with this definition and in "Drops" folder start appearing folders with build results.
I know this old but I just had this problem. Assuming you have a task of "Publish Artifacts". You can click on the result of a build and there will be an Artifacts tab that let you download the folder created in the publish artifacts task mentioned.

Visual Studio copys .config file to bin on build, but MSBuild does not

I have a WebAPI project in Visual Studio 2013. If I build the project in Visual Studio, in the bin/ directory I see a file called MyProject.dll.config, which represents the web.config file at build time.
However, if I execute MSBuild from the command line, the .config file is missing, but all other files are present.
> msbuild.exe /t:build /v:q /p:Configuration=Debug /nologo \
D:\Workspace\MyProject\src\MyProject.sln
What gives? Why isn't the .config copied?
For deploying a web project or a web api project, the fact that there's no $(TargetName)$(TargetExt).config isn't a big deal. At run-time, IIS will use Web.config to figure out everything it needs for your assembly.
BUT!
If you're using a Web App or Web Api project as the basis for testing* then you can hit some snags. In particular, when it comes to assembly binding redirects (as is the case with something within the bowels of MVC which still relies on Newtonsoft.Json 4.5.0 when the current version at time of writing is 7.0.0). A colleague had a similar issue with another assembly his test project was depending on.
Now when you run your tests through Visual Studio (eg, via Resharper), they all work just fine. However, when your tests get to the CI server and they are run by nunit-console, you'll see assembly load errors. Not pretty. This is because of the described behaviour where VS is sneakily copying the .config file to the correct output and msbuild isn't. However, you can work around this with a post-build build event:
copy $(ProjectDir)Web.Config $(TargetDir)$(TargetName)$(TargetExt).config
This has resolved my issues with redirects. I hope it helps someone else.
You may ask "Why use a Web App or Web API project as your test project?". A Web* project is a lot more comfortable to deal with as a base for a test project which deals with .net assemblies and JavaScript tests as JavaScript is properly recognised (syntax highlighting) and there's a Scripts folder which has the quick "Add -> Javascript File" menu item for itself and descendant folders, so I prefer to use this instead of a plain Class Library project.
When I create a WebAPI project the web.config Copy to Output Directory is set to Do Not Copy by default. Did you select the Web.config in Solution Explorer and set this to a copy action?
I'm at a loss to explain why it seems to copy for you with the IDE build but NOT the msbuild cmd you show, this is not the behavior I see with a fresh WebAPI project in 2013.

Missing bin/EntityFramework.xml file in Visual Studio 2010 and EF 4.1 DB First

Main Goal - To deploy a live version of my solution on an IIS. I am currently attempting to do so by building a deployment package through Visual Studio 2010.
Issue - When attempting to build a deployment package or publish my project within Visual Studio 2010, I get an error stating that 'bin/EntityFramework.xml' is missing.
I've done quite a bit of research and have not been able to find any information on how this file could have gone missing or how to restore/regenerate the file.
Questions - Is there any way to restore or regenerate the 'bin/EntityFramework.xml' file? Or, is there a simpler approach for deploying my VS 2010 solution to an IIS?
(FYI, I've already attempted copying the file structure to an IIS manually. This caused assembly issues, which is why I'm currently avoiding that approach.)
Thanks!
To answer the specific question first, you can easily regenerate this file by creating a new project of the same type (e.g. ASP.NET MVC3), then building that new project. EntityFramework.xml will appear in the new project's bin folder. You may then copy it over to your existing project.
However, you can just 'Exclude from Project' the missing file (via right-click in Solution Explorer), since it is not required to build, then you will achieve your goal of publishing the project through VS2010.

Resources