I have inherited a asp.net project that i'm trying to incorporate into our continuous integration tool. I've successfully got other C# web applications to compile via msbuild and into the CI, but this project seems different. It has no .csproj / .sln / .vsproj to open, and I open the project in visual studio 2012 via "Open Web Site"
Normally, the dev's will just run "Publish Web Site" via visual studio, and this is the process that I want to run over command line so that I can get it into our CI.
A lot of SO answers involve the .sln or .csproj file which I don't have, and also a publishing profile, which I don't have.
Any ideas or solutions on how I can get this project to publish via command line?
Related
We have two build servers and a newly created project has decided that it only wants to build successfully on one of them. It gives this error on the build server on which it fails:
MyLovelyNewProject.csproj(380,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found. Also, tried to find "WebApplications\Microsoft.WebApplication.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\MSBuild.exe.Config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.
Our DevOps guy investigated and determined that one server has the v15.0 build tools and one of them has the v15.9 build tools. The new project fails to build on the server that has the v15.9 build tools, since it's specifically looking for the v15.0 build tools.
All of our other projects build just fine on both build servers, but I wasn't able to find anything in their .sln or .csproj files that looked different from the new project. How can I retarget/reconfigure the new project so that it will build successfully regardless of which version of the build tools a given server has?
(If you want to suggest that DevOps synchronize the build servers to have the same version of the build tools, I agree! Alas, they're busy with a major server migration, and I would like the new project to not have a 50% chance of failing in CI while they're getting around to it.)
I think the issue is related to the Build Tool v15.9 rather than your projects. On that Server, you did not install the build workload for web projects on V15.9 Build Tool so that it cannot specify the web projects and lack the ability to build web projects. Or, the build tool is broken due to some reasons.
You could try the following steps:
1) try to open the vs_installer, click Modify
And select Web development build tools workload to install, also, if you have a asp net core web projects, do not forget to install .Net Core build tools workload.
To ensure this, I remove the web development build tools workload, and get the same issue for web project.
2) If it does not help, please click Repair for Build Tool V15.9 to repair it.
I've built a C# MVC web app (not CORE) and i integrated react into it. I have npm run build on first app build.
Debugging locally everything seems fine (got task runner for watch too), but theres a bit of a problem while trying to deploy/publish to azure.
My build folder (inside Visual Studio 2017) shows as empty even tho on every build there's a "bundle.js" in there (checked with windows explorer, it is there). This problem stops VS 2017 from publishing the react part of my app.
Any idea how i could make VS show that file and publish it to azure?
Fixed. Dragging and dropping the bundle.js into the folder made it work.
However...it seems that we cant use the BundleConfig if JS files come from NPM build so the only option is to use #Url.Content()
I changed jobs this year, so due to that i switched from Java to C#.In both jobs I work/worked on a large application that is deployed to a server and exposes various webservices.
With the Java job, an ant build process created a .ear file that contained a .war file and other objects. This .ear file was deployed by copying it into a directory within a JBoss/tomcat server. I understood the process fairly well.
With the C# job, I press a green triangle "play" button in Visual Studio and the application is compiled and somehow deployed to IIS, and Visual Studio then starts up a web browser pointing to the application's URL. I don't completely understand what is happening under the hood during this process. We have a build server that creates production builds that go out to production servers, but I don't understand a) what artifacts are produced by the build process, and b) how are those build artifacts deployed to IIS.
I would like to understand the process well enough to manually drive builds and deployments, re-automate the process, and also troubleshoot and modify our existing build and deploy process. I can drive a build with msbuild, but what does that produce, and how would I get it deployed onto another machine's IIS installation?
What happens when you hit Run (the green triangle) is probably not the best example, because it is using a specialized form of IIS (sometimes called Cassini) hosted within Visual Studio with a debugger attached.
To get a clearer picture of what happens when deploying, use the Publish tool to deploy to a folder on your desktop. In that folder you will see what is essentially the web root. Your project, minus any code files, and a bin directory with the compiled binaries.
Typically only static files such as html, css, and png, etc. will be deployed, while any code files won't. By default Visual Studio "knows" which files to build into the binary, and which to simply copy to the output folder (and which to ignore). But you can change this in cases where you need to override that behavior, or you have a file type VS doesn't know about. In your solution explorer, right click on a file, select properties. In the properties window for that file you'll see "build action", which shows what VS will do with that file.
Hope that helps.
Just add a note.
So,
If you are working with ASP.NET Website, it should enough to manually copy it to publish folder
If you are working with ASP.NET Web Application, so before publish it should be compiled. All compile operations is performed by MSBuild - command line utility to buld .net projects. But how MSBuild can understand, what it should build and in what way? Easy - there special files with instructions for MSBuild - is solution files (example howto build project from command line "C:\...\MSBuild.exe" /maxcpucount:10 MyAwesomeSolution.sln). Solution file contains references to project files (and build order for projects, etc), project files contains references to files, which included in project (and type of project - library/console/web app/etc, and framework version, and action for each file - build/content/resource, etc). If some file does not included to project, it will be ignored.
So, when you press green button, firstly VS will run MSBuild to build your solution. Inside solution should be written, which project will be used as starting point and what should be done before/after build. Inside project there information, howto debug project (via IIS, IIS express or smthg else).
So, when we working with some CI server, to compile our solution is enough to run MSBuild on CI server with path to solution. Ofcource, to publish compiled solution via CI, additional scripts should be written (to cpy files, etc).
Also, if you want to publish you website to some location, you can create "publish profile". It allows you to publis your website to IIS, FTP, etc, but you have to press "publish" button manually (right click on web project => publish)
I need to be able to generically and separately build and publish C# ASP.NET Web Applications. Ideally, I would like to use MSBuild to build the application, and if that succeeds, I would like to simply publish the site preferably solely with file copy.
Currently, I am able to build web application quite easily with MSBuild, but it is the publishing that is causing confusion. After the build, the binaries sit in the bin folder, but I am not sure what files to copy. What would be a good way to mimic the operations that VS's publish feature does, and still keeping everything generic?
You can invoke the Visual Studio web publish pipeline using the command line, check out this tutorial it shows you step by step how to do it:
Specifying the publish profile
You can specify the publish profile by name or by the full path to the .pubxml file, as shown in the following example:
msbuild C:\ContosoUniversity\ContosoUniversity.sln /p:DeployOnBuild=true /p:PublishProfile=C:\ContosoUniversity\ContosoUniversity\Properties\PublishProfiles\Test.pubxml
Web publish methods supported for command-line publishing
Three publish methods are supported for command line publishing:
MSDeploy - Publish by using Web Deploy.
Package - Publish by creating a Web Deploy Package. You have to install the package separately from the MSBuild command that creates it.
FileSystem - Publish by copying files to a specified folder.
http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment
The latest projects can be built by:
dotnet build MyWebsite.sln
For more info please refer the microsoft docs: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build
Note: Old ASP.NET projects are not supported. Please use MsBuild instead https://stackoverflow.com/a/24063993/1143349.
I have a C# web application developed and web deploy ready - meaning I have the WebApp.Web.zip file ready. I have verified that manual import of this application in my IIS 7.0 manager works and I am able to run the application in the browser.
Open IIS Manager (cmd->inetmgr), and explore the "Sites -> Default Web Site", and click on "Import Application" on the Right menu under Deploy. Browse to the path of the AAA.Web.zip and click "open". Go through the Package Import wizard. Click on "Browse *:80".
I now want to programmatically do the import of this application in the local IIS Server. Could you help me with some pointers?
So If all that you want is to host your WebApplication in IIS, and you don't want to do it all the way manually.
There is a neat way to do so,
Create a WebSetup Project. i.e. Add a New Project into the Solution of your Existing WebApplication i.e. inside visual studio, Add New Project, go to
Other Project Types >>Setup And Deployment >> Visual Studio Installer >> Web Setup Project
Just add Primary Output and Content Files of your WebApplication to the Setup Project and you are done. All you have to do is to build your solution.
And inside the bin folder of your Setup Project, you will get an .exe, which upon installation, hosts the WebApplication in IIS.
see more about creating a setup Project in visual studio
atleast it is cleaner than WebDeploy Command Line Syntax
Just use the webdeploy command line in your buildscript or from a Process object
http://technet.microsoft.com/en-us/library/dd569106(v=ws.10).aspx
Microsoft basically doesn't let you hook in with an API, there are a few ways to hack through it, but honestly you'll be better off using the command line
see this old answer