TrustedHosts
list. $nanoServerIpAddress = "10.83.181.14" Set-Item WSMan:\localhost\Client\TrustedHosts "$nanoServerIpAddress" -Concatenate -Force
$nanoServerIpAddress
variable with the IP address you are using.TrustedHosts
list, remotely connect to it using PowerShell. $nanoServerSession = New-PSSession -ComputerName $nanoServerIpAddress -Credential ~\Administrator Enter-PSSession $nanoServerSession
[10.83.181.14]: PS C:\Users\Administrator\Documents>
mkdir C:\PublishedApps\AspNetCoreSampleForNano netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes net share AspNetCoreSampleForNano=c:\PublishedApps\AspNetCoreSampleForNano /GRANT:EVERYONE`,FULL
\\<nanoserver-ip-address>\AspNetCoreSampleForNano
in the explorer on the host computer. New-NetFirewallRule -Name "AspNet5 IIS" -DisplayName "Allow HTTP on TCP/8000" -Protocol TCP -LocalPort 8000 -Action Allow -Enabled True
NanoServerPackage
provider by selecting it in the PowerShell collection. After installing and importing a supplier, you will be able to install Windows packages. Install-PackageProvider NanoServerPackage Import-PackageProvider NanoServerPackage Install-NanoServerPackage -Name Microsoft-NanoServer-Storage-Package Install-NanoServerPackage -Name Microsoft-NanoServer-IIS-Package
>Microsoft-NanoServer-Storage-Package
, a reboot is required. This is a temporary procedure and will not be needed in the future.http://<nanoserver-ip-address>/
- the start page should appear. When IIS is installed, a default website is created called Default Web Site
, which uses port 80. copy C:\windows\system32\inetsrv\aspnetcore.dll ``\\<nanoserver-ip-address>\AspNetCoreSampleForNano`` copy C:\windows\system32\inetsrv\config\schema\aspnetcore_schema.xml ``\\<nanoserver-ip-address>\AspNetCoreSampleForNano``
copy C:\PublishedApps\AspNetCoreSampleForNano\aspnetcore.dll C:\windows\system32\inetsrv\ copy C:\PublishedApps\AspNetCoreSampleForNano\aspnetcore_schema.xml C:\windows\system32\inetsrv\config\schema\
# Backup existing applicationHost.config copy C:\Windows\System32\inetsrv\config\applicationHost.config C:\Windows\System32\inetsrv\config\applicationHost_BeforeInstallingANCM.config Import-Module IISAdministration # Initialize variables $aspNetCoreHandlerFilePath="C:\windows\system32\inetsrv\aspnetcore.dll" Reset-IISServerManager -confirm:$false $sm = Get-IISServerManager # Add AppSettings section $sm.GetApplicationHostConfiguration().RootSectionGroup.Sections.Add("appSettings") # Set Allow for handlers section $appHostconfig = $sm.GetApplicationHostConfiguration() $section = $appHostconfig.GetSection("system.webServer/handlers") $section.OverrideMode="Allow" # Add aspNetCore section to system.webServer $sectionaspNetCore = $appHostConfig.RootSectionGroup.SectionGroups["system.webServer"].Sections.Add("aspNetCore") $sectionaspNetCore.OverrideModeDefault = "Allow" $sm.CommitChanges() # Configure globalModule Reset-IISServerManager -confirm:$false $globalModules = Get-IISConfigSection "system.webServer/globalModules" | Get-IISConfigCollection New-IISConfigCollectionElement $globalModules -ConfigAttribute @{"name"="AspNetCoreModule";"image"=$aspNetCoreHandlerFilePath} # Configure module $modules = Get-IISConfigSection "system.webServer/modules" | Get-IISConfigCollection New-IISConfigCollectionElement $modules -ConfigAttribute @{"name"="AspNetCoreModule"} # Backup existing applicationHost.config copy C:\Windows\System32\inetsrv\config\applicationHost.config C:\Windows\System32\inetsrv\config\applicationHost_AfterInstallingANCM.config
aspnetcore.dll
and aspnetcore_schema.xml
from the share directory after the previous step is completed. $SourcePath = "https://go.microsoft.com/fwlink/?LinkID=809115" $DestinationPath = "C:\dotnet" $EditionId = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name 'EditionID').EditionId if (($EditionId -eq "ServerStandardNano") -or ($EditionId -eq "ServerDataCenterNano") -or ($EditionId -eq "NanoServer") -or ($EditionId -eq "ServerTuva")) { $TempPath = [System.IO.Path]::GetTempFileName() if (($SourcePath -as [System.URI]).AbsoluteURI -ne $null) { $handler = New-Object System.Net.Http.HttpClientHandler $client = New-Object System.Net.Http.HttpClient($handler) $client.Timeout = New-Object System.TimeSpan(0, 30, 0) $cancelTokenSource = [System.Threading.CancellationTokenSource]::new() $responseMsg = $client.GetAsync([System.Uri]::new($SourcePath), $cancelTokenSource.Token) $responseMsg.Wait() if (!$responseMsg.IsCanceled) { $response = $responseMsg.Result if ($response.IsSuccessStatusCode) { $downloadedFileStream = [System.IO.FileStream]::new($TempPath, [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) $copyStreamOp = $response.Content.CopyToAsync($downloadedFileStream) $copyStreamOp.Wait() $downloadedFileStream.Close() if ($copyStreamOp.Exception -ne $null) { throw $copyStreamOp.Exception } } } } else { throw "Cannot copy from $SourcePath" } [System.IO.Compression.ZipFile]::ExtractToDirectory($TempPath, $DestinationPath) Remove-Item $Temp</code> Path }
web.config
to indicate the directory in which the dotnet.exe
file is dotnet.exe
. Another way is to copy the dotnet.exe
file to the same directory.web.config
in a situation where the dotnet.exe
file dotnet.exe
not copied to the same directory: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="C:\dotnet\dotnet.exe" arguments=".\AspNetCoreSampleForNano.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true" /> </system.webServer> </configuration>
DefaultAppPool
to simplify. For more information on working with the application pool, see the Application Pools article. Import-module IISAdministration New-IISSite -Name "AspNetCore" -PhysicalPath c:\PublishedApps\AspNetCoreSampleForNano -BindingInformation "*:8000:"
c:\windows\system32\forwarders
directory to the c:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.0\
and directory to the .NET Core c:\dotnet
binary .NET Core c:\dotnet
(in this example). This is caused by a bug that is fixed in newer versions.dotnet publish
command, also copy the DLL files from the c:\windows\system32\forwarders
directory to the publishing directory.http://<nanoserver-ip-address>:8000
. If logging is configured as described in Creating and forwarding logs , all logs are available in the C:\PublishedApps\AspNetCoreSampleForNano\logs
.Source: https://habr.com/ru/post/310996/
All Articles