PowerShell
-
Create symbolic link from folder to folder.
move C:\ProgramData\docker\* D:\ProgramData\docker
cmd /c mklink /d C:\ProgramData\docker D:\ProgramData\docker
# /d for folder
-
HTTP error 500.30 – ANCM in-process start failure
-
ANCM == AspNetCoreModule
-
Issue: Logging to specific log folder permission denied
-
Solve:
-
Get issue detail by opening stdoutLogEnabled="true" in web.config.
-
Set log folder permission "Read/Write/Modify" to local user "IIS_IUSRS".

-
Json config with strong type
在 Startup.ConfigureServices 透過 services.Configure<T>()以強型別對應 IConfiguration 實例的方式,加入至 DI 容器:
Startup.cs
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// …
public class Startup
{
private IConfiguration _config;
public Startup(IConfiguration config)
{
_config = config;
}
public void ConfigureServices(IServiceCollection services)
{
// …
services.Configure<Settings>(_config);
}
// …
}
|
使用的 DI 型別改成 IOptions<T>,如下:
Controllers\HomeController.cs
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace MyWebsite.Controllers
{
public class HomeController : Controller
{
private readonly Settings _settings;
public HomeController(IOptions<Settings> settings)
{
_settings = settings.Value;
}
public string Index()
{
var defaultCulture = _settings.SupportedCultures[1];
var subProperty1 = _settings.CustomObject.Property.SubProperty1;
var subProperty2 = _settings.CustomObject.Property.SubProperty2;
var subProperty3 = _settings.CustomObject.Property.SubProperty3;
return $"defaultCulture({defaultCulture.GetType()}): {defaultCulture}\r\n"
+ $"subProperty1({subProperty1.GetType()}): {subProperty1}\r\n"
+ $"subProperty2({subProperty2.GetType()}): {subProperty2}\r\n"
+ $"subProperty3({subProperty3.GetType()}): {subProperty3}\r\n";
}
}
}
|
輸出結果如下:
|
1
2
3
4
|
defaultCulture(System.String): zh-TW
subProperty1(System.Int32): 1
subProperty2(System.Boolean): True
subProperty3(System.String): This is sub property.
|
這樣就可以是強型別,且有明確的型態。
-
Got 502.3 error when upgrading .Net.Core version
-
Error message:
An assembly specified in the application dependencies manifest (CloudKeyPool.deps.json) was not found:
package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1'
path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files: aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml
-
Solution: Add the follows into .csproj file.
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
-
Enable IIS Debug log
編輯 web.config 檔案。 將 stdoutLogEnabled 設定為 true,並將 stdoutLogFile 路徑變更為指向 [logs] 資料夾 (例如 .\logs\stdout)。 路徑中的 stdout 是記錄檔名稱前置詞。 建立記錄檔時,系統會自動新增時間戳記、處理序識別碼及副檔名。 使用 stdout 作為檔案名稱前置詞時,一般記錄檔會命名為stdout_20180205184032_5412.log。
-
Error NETSDK1004 Assets file 'D:\{solutionPath}\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
-
Tools > NuGet Package Manager > Package Manager Console and run:
dotnet restore
-
How to debug with local NuGet packages
-
Put *.nupkg at specific folder, and add this folder into Tools -> Options -> Add a new NuGet source.

-
Make the new source checked ONLY (avoid other confusing packages)
-
Refresh NuGet list.
-
Change Nuget feed/source posiition
C:\Users\{{UserName}}\AppData\Roaming\NuGet\NuGet.Config
=== NuGet.Config ===
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="{{new-source}}" value="{{serverLink}}" />
</packageSources>
</configuration>
-
Check the log of windows service
-
"Computer Management" -> "Event Viewer" -> "Windows Logs" -> "System" -> filter by "Service Control Manager"

PowerShell
-
Got path not exists
-
Error message:
"{path} No such file or directory"
-
Remove the "" on the path behind `cat` command.
git secrets –add-provider — cat ./folder/*
-
Got path not exists
-
Error message:
#Net #Netcore #Powershell
Leave a Reply