Visual Studio For Mac Publish To Iis

By Daniel Roth, Steve Smith and Rick Anderson

This article will show you how to write your first ASP.NET Core application on a Mac.

Sections:

To setup your development machine download and install .NET Core and Visual Studio Code with the C# extension.

Download heroes of might and magic 3 for mac. Follow the instruction in Building Projects with Yeoman to create an ASP.NET Core project.

Select an ASP.NET Core project in the Solution Explorer, press Ctrl+N or right-click and choose Add, then select Publish XML. If you are editing a run configuration of the Publish to IIS type, click + next to the Publish profile field. In the dialog that opens, specify a name for the profile and select its type. With Visual Studio for Mac you can write in C#, F#, Razor, HTML5, CSS, Javascript, Typescript, XAML, and XML. With the power of Roslyn, Visual Studio for Mac brings IntelliSense to your fingertips. IntelliSense describes APIs as you type and uses auto-completion to increase the speed and accuracy of.

  • Start Visual Studio Code
  • Tap File > Open and navigate to your Empty ASP.NET Core app

From a Terminal / bash prompt, run dotnetrestore to restore the project’s dependencies. Alternately, you can enter commandshiftp in Visual Studio Code and then type dot as shown:

You can run commands directly from within Visual Studio Code, including dotnetrestore and any tools referenced in the project.json file, as well as custom tasks defined in .vscode/tasks.json.

This empty project template simply displays “Hello World!”. Open Startup.cs in Visual Studio Code to see how this is configured:

If this is your first time using Visual Studio Code (or just Code for short), note that it provides a very streamlined, fast, clean interface for quickly working with files, while still providing tooling to make writing code extremely productive.

In the left navigation bar, there are four icons, representing four viewlets:

  • Explore
  • Search
  • Git
  • Debug

The Explore viewlet allows you to quickly navigate within the folder system, as well as easily see the files you are currently working with. It displays a badge to indicate whether any files have unsaved changes, and new folders and files can easily be created (without having to open a separate dialog window). You can easily Save All from a menu option that appears on mouse over, as well.

The Search viewlet allows you to quickly search within the folder structure, searching filenames as well as contents.

Code will integrate with Git if it is installed on your system. You can easily initialize a new repository, make commits, and push changes from the Git viewlet.

The Debug viewlet supports interactive debugging of applications.

Finally, Code’s editor has a ton of great features. You’ll notice unused using statements are underlined and can be removed automatically by using command. when the lightbulb icon appears. Classes and methods also display how many references there are in the project to them. If you’re coming from Visual Studio, Code includes many of the same keyboard shortcuts, such as commandkc to comment a block of code, and commandku to uncomment.

The sample is configured to use Kestrel for the web server. You can see it configured in the project.json file, where it is specified as a dependency.

  • Run dotnetrun command to launch the app
  • Navigate to localhost:5000:
  • To stop the web server enter Ctrl+C.

Once you’ve developed your application, you can easily use the Git integration built into Visual Studio Code to push updates to production, hosted on Microsoft Azure.

Initialize Git¶

Initialize Git in the folder you’re working in. Tap on the Git viewlet and click the InitializeGitrepository button.

Add a commit message and tap enter or tap the checkmark icon to commit the staged files.

Git is tracking changes, so if you make an update to a file, the Git viewlet will display the files that have changed since your last commit.

Initialize Azure Website¶

You can deploy to Azure Web Apps directly using Git.

  • Create a new Web App in Azure. If you don’t have an Azure account, you can create a free trial.
  • Configure the Web App in Azure to support continuous deployment using Git.

Record the Git URL for the Web App from the Azure portal:

  • In a Terminal window, add a remote named azure with the Git URL you noted previously.

    • gitremoteaddazurehttps://ardalis-git@firstaspnetcoremac.scm.azurewebsites.net:443/firstaspnetcoremac.git
  • Push to master.

    • gitpushazuremaster to deploy.
  • Browse to the newly deployed web app. You should see Helloworld!

-->

You can use the Publish tool to publish .NET Core Console or ASP.NET Core apps to a folder.

Prerequisites

  • Visual Studio 2019 for Mac installed with .NET Core enabled.
  • A .NET Core console or ASP.NET Core project. If you don’t already have a project, you can create a new one.

Publish to Folder

Using Visual Studio for Mac you can publish your .NET Core projects to a folder using the Publish tool. After publishing to a folder you can transfer the files to a different environment. To publish to a folder follow these steps.

  1. In the Solution Pad, right-click the project and choose Publish.

  2. If you have previously published this project, you'll see the publish profile in the menu. Select that publish profile to start the publish process.

  3. To publish this project to a folder for the first time, select Publish to Folder

  4. The Publish to Folder dialog appears. On this dialog you can customize the folder where the project will be published. You can use the Browse button to do this, or paste in a path.

  5. After clicking Publish a few things happen. First a publish profile is created. A publish profile is an MSBuild file that is imported into the project during the publish process. It contains the properties that are used during the publish process. These files are stored in the Properties/PublishProfiles and have the extension .pubxml. Next, the publish process is started. You can monitor the progress by watching the status bar in Visual Studio for Mac.

  6. Once publish completes successfully a Finder window will open to the publish folder. Now that a publish profile has been created, it will be displayed in the Publish context menu.

  7. To publish the project again with the same settings you can click on the profile in the publish context menu.

Customize Publish Options

To change the name of the publish profile (which is displayed in the publish context menu), rename the publish profile file. Make sure to not change the extension of the file (.pubxml).

To change the publish folder path, open the publish profile and edit the publishUrl value.

To change the build configuration that is used, change the LastUsedBuildConfiguration property in the publish profile.