29

I am giving Rider a try, and so far, quite like it.

One feature I use in Visual Studio quite often is right click on a web project and publish to our testing server.

I cannot find a similar option in Rider, so what I have done is, create a run configuration, with the following settings:

  • Exe path: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/amd64/msbuild.exe
  • Arguments: MySolution.sln /m /p:DeployOnBuild=True /p:PublishProfile=My-Project "/p:platform=Any CPU" /p:configuration=Release /p:VisualStudioVersion=15.0 /p:Password=****
  • Working Directory: C:\SolutionFolder

When I want to publish, I select it from the drop-down and click run.
This works 100%.

My question is, is this the best way to do it, sans setting up a CI pipeline? Am I missing an option or setting in the IDE?

Settings

Pang
  • 9,564
  • 146
  • 81
  • 122
JonathanPeel
  • 743
  • 1
  • 7
  • 19
  • I try your solution by got Warning: unparsed command line arguments: – Jongz Puangput Jul 27 '17 at 07:33
  • Does it seem to a warning from Rider or MSBuild? I have never checked if I got any warnings, if it still works, maybe some arguments are not necessary. – JonathanPeel Jul 27 '17 at 12:06
  • I think from Rider – Jongz Puangput Jul 27 '17 at 12:24
  • This is still working for me. a few things you can check. 1) check the bath of MSBuild. 2) Make sure you have a publish profile. This is an XML file under _.My Project\PublishProfiles_ (it can be created with Visual Studio) – JonathanPeel Jul 28 '17 at 13:41
  • 2
    You can also try running this from the command line, from the solution folder use `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe" Musketeer.sln /m /p:DeployOnBuild=True /p:PublishProfile=Musketeer-Web "/p:platform=Any CPU" /p:configuration=Release /p:VisualStudioVersion=15.0 /p:Password=mYuBeRpAsS` just replacing SLN, publish profile, password, etc. – JonathanPeel Jul 28 '17 at 13:44
  • I have also added a screenshot as a reference to you. – JonathanPeel Jul 28 '17 at 13:48
  • Thanks for this, I had to add allowuntrusted to mine: Your.sln /p:DeployOnBuild=true /p:PublishProfile="Your Profile" /p:Password=PasswordInProfile /p:AllowUntrustedCertificate=true – chrispepper1989 Apr 13 '18 at 12:08

2 Answers2

16

As of June 2018, Rider doesn't have UI for publishing.

There is a feature request which you can vote for, once logged in YouTrack.

As a workaround, one can create a '.NET Executable' configuration like you did, and run it when you want to publish your project.

More detailed instructions follows:

  1. Run > Edit Configuration
  2. Add new configuration > .NET Executable
  3. Name = your project name
  4. Exe path = path to your MSBuild (for example C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/amd64/MSBuild.exe)
  5. Program arguments = YourSolution.sln /t:"Your_Project" /p:PublishProfile=YourPublishProfile.pubxml /p:Configuration=Debug /p:DeployOnBuild=true /m
  6. Working directory = C:/path/to/solution/dir/

Notes:

  • the project publish profile is usually located in the project folder, under Properties/PublishProfiles. If you don't have one you can start with the example reported below;
  • you need to replace the dots (.) in the project name with underscores (_). In the example above Your.Project was passed as Your_Project;
  • you can specify a different publishing directory, if not already specified in the publish profile, by adding the argument /p:PublishDir="C:/path/to/publish/dir/";
  • if you don't have Visual Studio installed on your machine, you can use the MSBuild bundled with the Build Tools for Visual Studio 2017.

Example of publish profile:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>..\YourPublishDirectory</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <ExcludeFilesFromDeployment>bin\*.dll.config</ExcludeFilesFromDeployment>
  </PropertyGroup>
</Project>
Pang
  • 9,564
  • 146
  • 81
  • 122
Marco Lackovic
  • 6,077
  • 7
  • 55
  • 56
  • I found the same approach working in Rider for Mac for publishing a WebJob project to Azure WebJob. I've used "Native Executable" instead of ".NET Executable" and the following MSBuild path: `/Library/Frameworks/Mono.framework/Versions/Current/bin/msbuild`. Also, had to specify the publishing profile password using `/p:Password=$PublishingProfilePasswordHere$` – Crulex Oct 17 '19 at 14:00
  • @Crulex where can I find this password if I downloaded a `*.PublishSettings` file directly fro Azure? VS never asked for a password and can deploy to the specific slot without issues. – Bruno Finger Aug 03 '20 at 10:59
  • The password should be inside the `.PublishSettings` file. – Crulex Sep 14 '20 at 05:49
  • "the Publish option should be in the right-click menu of your solution in the Solution Explorer tool window" -- https://rider-support.jetbrains.com/hc/en-us/community/posts/360000150164/comments/360001750239 – Pang Dec 14 '20 at 00:54
  • 1
    Rider DOES now have a UI for publishing (For those reading this older post). – Charles Burns Aug 09 '22 at 13:44
3

Latest versions of Rider support publishing via UI. If you don't have Visual Studio installed on your machine, make sure the web project has Build.Microsoft.VisualStudio.Web.targets nuget package installed.