I'm doing build & deploy content in Visual Studio but this takes a lot of space (170 MB) because it contains runtime (dnx core clr) and all packages files.
Can I deploy web app to windows server and automatically install runtime and all packages on server for my web app?
You can scripted it to download the runtime as you instal it.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Dependencies can be then be dowloaded using the dnu restore command based on you project.json file.
Related
I have a .NET 6 Windows Desktop app that I deploy with MSIX.
I can run and debug it on my own computer, but it fails to build with Azure Pipelines YAML.
I get the error:
C:\Program
Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5):
error NETSDK1047: Assets file 'D:\a\1\s\MyApp\obj\project.assets.json'
doesn't have a target for 'net6.0-windows10.0.19041.0/win-x64'. Ensure
that restore has run and that you have included
'net6.0-windows10.0.19041.0' in the TargetFrameworks for your project.
You may also need to include 'win-x64' in your project's
RuntimeIdentifiers.
App project file:
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
Installer project file:
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
The pipeline task is VSBuild with Visual Studio 2022 (v. 17)
Nuget tool is version 6.0 installed with NugetToolInstaller task.
Azure Windows agent uses vmImage: 'windows-2022'
The error says:
Ensure that you have included 'net6.0-windows10.0.19041.0' in the
TargetFrameworks for your project. You may also need to include
'win-x64' in your project's RuntimeIdentifiers.
I have added 'net6.0-windows10.0.19041.0' in the TargetFramework for both the app and the installer projects.
If I replace win10-x64 with win-x64 it can build, but I need to use win10-x64 because one of the packages requires it (Microsoft.PowerShell.SDK with System.Management.Automation).
NEW:
After adding /p:RestoreLockedMode=true in the VS Build task, I now get the error:
MyApp.Installer.wapproj : error NU1004: The project MyApp has no
compatible target framework. The packages lock file is inconsistent
with the project dependencies so restore can't be run in locked mode.
Disable the RestoreLockedMode MSBuild property or pass an explicit
--force-evaluate option to run restore to update the lock file.
NEW NEW: I upgraded to .NET 7 but get the same error.
How do I fix the error?
I am working to publish my project to vps server Linux
Can i publish project from visual studio with sdk and runtime files
without install sdks and runtime to my server ?
when you publish you can chose to include all the packages needed by the project by making it "self contained" here is the command line to build it:
dotnet publish -o c:\temp\yourproject --self-contained -r linux-x64
I have an Ubuntu 18.04 x64 Linux server running a bunch of .NET Core applications. All of them are published as self-contained applications and .NET Core versions vary between 2.1, 3.1 and 5.0. I don't have .NET Core runtime (let alone SDK) installed on the machine and do not want to install it.
I want to run tools such as dotnet-sos, dotnet-dump and dotnet-gcdump for a .NET Core 3.1 self-contained application. The linked pages provide direct download links for them, e.g. https://aka.ms/dotnet-sos/linux-x64. However, when I run the downloaded dotnet-sos tool it fails with
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/var/tmp/.net/MY_USERNAME/dotnet-sos/mrdxw5vu.czm/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.18.04-x64
This happens even if the current working directory is my .NET application directory, which contains
libhostfxr.so. The error implies that running the tool for a self-contained application should be possible, but the file indeed does not exist in /var/tmp/.net/MY_USERNAME/dotnet-sos/mrdxw5vu.czm/. If I manually copy that file to the above directory it then fails with
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.18.04-x64
How do I run such tools without installing the .NET runtime machine-wide? I can easily download the binaries from https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-3.1.14-linux-x64-binaries but where do I put them for the tool to find them?
Turns out the .NET SDK can be extracted to any directory and then used to install and run dotnet-dump and dotnet-gcdump like this:
curl -fsSL https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash -s -- --no-path --install-dir ~/dotnet-sdk --channel 5.0
~/dotnet-sdk/dotnet tool install --tool-path ~/dotnet-sdk/tools dotnet-dump
DOTNET_ROOT=~/dotnet-sdk ~/dotnet-sdk/tools/dotnet-dump collect -p PID_TO_DUMP
(I did not manage to get SOS working in LLDB, however. "Installing" it works just as above, but it fails to load in LLDB.)
I want to publish my dotnet core app to IIS from mac. I use VS code for code writing and Dotnet Core 1.1 for publishing to local directory. (for example: bin/release/publish). There are compiled my files, ready to copy to IIS. On my IIS I currently have installed web deploy 3.6 and this is my VPS machine. Is there elegant way, how to copy files? The another way is using docker, but in this case I have the same problem. Generated docker file with docker publisher tool and I need to copy from mac os.
Thank you for your time.
From a terminal window navigate to the folder where your .csproj file is. From there run 'dotnet publish -c release'. A folder called publish will be created in bin/Release/netcoreappX.X. You can copy those files to the appropriate directory on your server. If you need help setting up IIS, follow the link below.
https://learn.microsoft.com/en-us/aspnet/core/publishing/iis
You can also run 'dotnet publish -h' to see all of the different arguments you can pass to the publish command.
Web Deploy (msdeploy.exe) seems to work in Mono, at least in WSL (Ubuntu 18.04). The tricky part is to extract the msi package somehow, which you can do easily on a Windows machine (you'll find the files in C:\Program Files\IIS\Microsoft Web Deploy V3).
Once you install Mono and obtain msdeploy.exe, just call the command, e.g.
mono msdeploy.exe -verb:sync -source:contentPath=/mnt/c/Data -dest:contentPath=test,ComputerName=https://example.com:8172/msdeploy.axd,UserName=WDeployAdmin,Password=PASSWORD,IncludeAcls=False,AuthType=Basic -enableRule:AppOffline -enableRule:DoNotDeleteRule -verbose -allowUntrusted:true
This lets you sync/copy the contents of /mnt/c/Data with the test web site in IIS on example.com with Web Deploy enabled.
Currently I am working on a mvc3 project and I use msbuild command line tool to do the packaging.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>msbuild MVC-Client.csproj /t:package /P:Configuration=staging
In my machine this command executes successfully and it creates a deploy-able package.And in deploy bat file it has following web deployment configs.
MSDeployPath="C:\Program Files (x86)\IIS\**Microsoft Web Deploy V2**\"
And but when I am trying to run same msbuild command in my build server machine(jenkings server) it creates a different bat file with following web deployment configs.
set MSDeployPath="C:\Program Files (x86)\IIS\Microsoft Web Deploy\"
In both machines I use same version of msbuild. And also i have both msdeply1 and msdeploy2 installed in those machines. What could be the reason for this ? I am using Microsoft (R) Build Engine Version 4.0.30319.1 version of msbuild.
Thanks
It's seems that install web deploy v1 after Web deploy v2, try to reinstall Web Deploy v2 on your build server.