Visual studio 2010 dialog halts automated build - asp.net

I am working on a project with a build that is automated using NAnt. The automated build includes NAnt tasks to clean the machine, including deleting and re-creating the virtual directory, clearing out VSWebCache, etc. Once the machine is reset, it attempts to compile the site with this:
<exec program="${visualstudio.install.dir}\devenv.com" commandline="SolutionFile.sln" failonerror="true"/>
The problem is that the automated build locks up at this point.
If I open the .sln file interactively, the first thing that happens is Visual Studio prompts me with a dialog box. I suspect this dialog box is "opening" (invisibly) when I run the NAnt script and I can't click on it to proceed.
The dialog message is:
Microsoft Visual Studio
The web (URL) is currently configured for use with ASP.NET 1.1. Web project (name) is targeting ASP.NET 4.0; if not configured some features may make incorrect assumptions, and pages designed with the tool may not render correctly.
Would you like the site to be configured for use with ASP.NET 4.0?
I do in fact have 3 different versions of .NET on my machine-- I work on multiple projects. I can't configure the site ahead of time because the build script will blow away my configuration anyway. I guess what I need is either an automated way to accept the dialog (as if I clicked the YES button) or a NAnt task that will automatically set up the vdir to be an ASP.NET 4.0 application.
I do have free reign to modify the build script as I see fit, but I cannot simply remove the portion that resets the machine-- our build box is shared with other projects and we have to reset everything to a known good state before running our compile.

Use MSBUILD directly, don't use devenv. It's the full IDE, and all you need is to build.

Related

How do I run an ASP.Net Core executable file?

I am new to ASP.Net Core. I have been following a tutuorial. I got to the point at which Javascript code was added to my project. I ran my program, and nothing in the script worked. After adding a few alert() calls, it was apparent that my program was not finding my script. People here and at Reddit suggested I look at the network tab of DevTools. I saw that my program was not able to find any js or css files.
Being an old-school C++/C# developer, I was running the program from a command window by going to the folder containing the executable file and typing the name of the file.
I went back to the beginning. The tutorial directs me to use the dotnet command, which is brand new to me. The first time it tells me to run my program, it tells me to go to the project directory and enter "dotnet run". It just hit me like a ton of bricks that that was what I should have done the first time. I went back to that project, used "dotnet run", and it worked.
So, my question is this: is it possible to run MyProject.exe by itself? If so, how? Copy it into my project folder? Or is the "dotnet run" command the standard way of executing an ASP.Net Core application?
I think it won't work if you directly run it (not sure if we can run MVC project using dotnet-cli (dotnet run will try to load only MSIL to CLR)).
DotNet core console application is different from .net core MVC projects
you can run your project by following ways.
1. Run using visual studio
when you create an MVC application, in the visual studio there will be multiple options to run it, you can choose IISexpress one, it will open in the default browser.
for step by step guide -> https://learn.microsoft.com/en-us/visualstudio/ide/quickstart-aspnet-core?view=vs-2019
2. publish it in IIS
For this you need to ensure few things, like hosting bundle is installed or not, IIS is correctly configured for core application or not.
for step by step guide -> https://stackify.com/how-to-deploy-asp-net-core-to-iis/
3. Use VSCode
for step by step guide -> https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-webapp-using-vscode?view=aspnetcore-3.1

How to enable compilation on the fly in Visual Studio

I have an ASP.NET Core 2.2 application. I run it using Ctrl+F5. But if I change C# code, I don't see changes after refreshing the website in the browser. How can I compile on the fly?
This happens automatically when running out of process. More likely than not, you're working on an ASP.NET Core 2.2 app, where the default process model has now been changed to in process. When running in this model, you must explicitly rebuild. You can edit your project properties to switch back to out of process if you like.

What sets the type to "Managed" when running web services under IIS Express?

As per the question, how do I configure an ASP.NET MVC project when running from Visual Studio 2013 under IIS Express (x64) to be seen as a "Managed" type in the debugger "Attach to Process" screen?
My solution always used to allow me to debug the web projects when running, and now I can no longer do so as the projects all seem to run as x64 non-managed.
I'm guessing it's something I have changed under the csproj or MSBuild targets / properties.
Regards,
Rob.
In the end, it appeared this was a combination of bloated csproj files, coupled with instability in Visual Studio 2013.
If you are using Visual Studio 2013, I highly recommend installing Update 2. It appears to make tasks a lot more reliable.
I never figured out what governs the Managed setting, however I have found the following option:
Click Attach to Process
Underneath Transport/Qualifier/Transport Information, there is a box marked Attach To:
By default, it is set to perform Automatic selection.
Click the Select button.
Toggle from Automatic to "Debug these code types"
Tick one or the other (not both) of the entries for "Managed ([.NET version])"
Click OK
I have had some success in getting the Debugger to attach properly to the IIS Express processes that are running Managed debuggable code that it "automatically" doesn't let me (for seemingly random reasons).

.NET - How to debug a DLL?

I need to debug a class library project that is provided to the main project (an ASP.NET website) as a DLL. For example, I need to put some breakpoints in order to check what's happening during the execution.
I tried How to: Debug from a DLL Project, unfortunately it didn't work...
How can I do it?
PS: I have the source code!
If you have the source code, and the .pdb files in your BIN directory, then you can debug through that code. However, You will need to enable external code debugging in Visual Studio.
You need to uncheck the "Enable Just My Code" option: menu Tools --> Options --> Debugging --> Enable Just My Code
NOTE: This will only work for .NET assemblies.
Debugging DLLs in Visual Studio (see #2 in the list) may be what you're looking for (full disclosure: Yes, this is my personal web site).
With method #1, you can't watch variables.
With method #2, step #2, if you can't open the project in the same Visual Studio instance, you can run the binary of the project (that is, run it outside of Visual Studio, but make sure you run the debug version.) and attach the Visual Studio debugger to it (menu Debug -> Attach to Process).
Here are the steps for method #2 so no one has to follow the link:
Attaching a using process to the DLL project. This involved hooking the Visual Studio debugger into a running process.
Open the DLL project in Visual Studio.
Run an application that uses the DLL. This
application can't be run from
another instance of Visual Studio since the
process will already have a debugger
attached to it.
From here you can add breakpoints and step through
the DLL code loaded in Visual Studio (although
the breakpoint will appear disabled
the same as in method 1).
When you build the class library project, the .pdb file is created in the Debug or Release folder of that class library. These two file are referred to by the ASP.NET project when you right click and select the option "Add a Reference" and point to the DLL file of the class library project.

Is There a Visual Studio 2005 ASP.NET debug and release build

Is there a "debug" and "release" build in VS 2005? If so, how do I switch between the two?
Saif:
Are you working on an ASP.NET web site project?
If so, Visual Studio delegates the build step to the ASP.NET runtime, and the ASP.NET runtime picks up debug versus release in the web.config .
I have a post on the topic that will help: Debug and Release Builds in ASP.NET 2.0
Note that a couple things have changed since that time. Namely, MSFT released two add-ins for VS 2005 - one to add real web application projects that have debug and release settings (for the code-behind and loose c# files), and they also released web deployment projects, which can use the asp.net command line compiler. Web App projects became a part of VS2005 in SP1, too.
Use the Configuration Manager. Right-click on your solution in the Solution Explorer, select "Configuration Manager...", and change the active solution configuration.
You can change your project's behavior when in debug or release mode. Bring up your project properties pane, select the appropriate configuration from the dropdowns at top, and change the settings as appropriate. Notice that some changes are made by default for you. For instance, release builds by default are set to optimize code, and debug builds are not.
In the ASP.NET web.config file there is a debug="true" attribute. The first time you run the web application Visual Studio will ask you if you want to turn on debugging, selecting yes will cause Visual Studio to edit the config file for you.
Just remember to make sure you change that back to false for your release builds. For more info click here.
The quick way is to right click on the toolbars and turn on the standard toobar. Then you can quickly change between build targets by choosing the one you want from the solutions configuration drop down.
If you want to change what those configurations do, then follow what Michael Petrotta said in his answer.

Resources