Reputation: 2507
I already know about the .NET Core 'publish' command and how to publish for different platforms. E.g.:
dotnet publish -c Release -f netcoreapp2.0 -r win10-x64
However, I was wondering is there a way to specify those parameters directly in a .csproj file ?
(I am aware of <RuntimeIdentifier>
property, but using this, a published app is not standalone, and more importantly, any native libraries residing in the 'runtimes/(OS)/native/' are not copied.)
Am I missing something ?
Edit: How can I deploy an standalone .NET Core app using VS IDE (to produce the same output as the command I wrote before (dotnet publish ...), preferably by modifying csproj file ?
The question seems to be a clone of: Publish .net core app from VS 2017 (apologize, have not seen that earlier).
Upvotes: 2
Views: 1348
Reputation: 9936
No, publish details can't be stored in csproj
. If you create a publishing profile in Visual Studio, the details are saved in pubxml
and pubxml.user
files stored in the Properties\PublishProfiles
folder inside the project folder.
The contents of pubxml
vary depending on the publish target (for example, Azure versus local folder), and they aren't documented. It seems Microsoft really just wants you to create them through Visual Studio. The most recent docs I can find here even carry the following warning:
The .pubxml file shouldn't be checked into source control because it depends on the .user file. The .user file should never be checked into source control because it can contain sensitive information and it's only valid for one user and machine.
That doesn't strike me as very enterprise- or teamwork-friendly, where you'd probably want to standardize publish settings, but it's what we have today. The other reason this seems odd to me is that the profiles contain a lot of settings that can only be modified by hand (for example, the Azure website profiles have <LaunchSiteAfterPublish>
set to true, which is a pretty annoying default if your site runs under a different URL).
The github repo for all of this stuff is aspnet/websdk.
If you really want to stick to the command line (as someone who grew up with no alternatives, I really don't understand that trend), you can reference an existing publishing profile this way:
dotnet publish WebApplication.csproj /p:PublishProfile=<FolderProfileName>
Upvotes: 3