--- lang: ja-jp breaks: true --- # MSBuild New .csproj (SDK Style) cannot reference GAC assemblies 2022-07-01 > New .csproj cannot reference GAC assemblies > https://github.com/dotnet/sdk/issues/987 > Adding this to the bottom of the new csproj and reopening the solution fixes all problems: ```xml= <!-- Workaround for https://github.com/dotnet/roslyn-project-system/issues/1739 --> <PropertyGroup> <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths> </PropertyGroup> ``` :::warning ビルド時に参照アセンブリを解決するときに検索する場所のリストです。 このリストでは、先頭から順に優先度が低くなるため、パスを指定する順序が意味を持ちます。 ::: > Resolving file references in team build ( Part -2 ) > https://docs.microsoft.com/ja-jp/archive/blogs/manishagarwal/resolving-file-references-in-team-build-part-2 :::warning 上記、`AssemblySearchPaths`の設定を行った場合、`HintPath`よりも、`ReferencePath` のアセンブリが優先される。 ::: > Do not use HintPath for added metadata references #3867 > https://github.com/dotnet/project-system/issues/3867 :::warning `AssemblySearchPaths`を使用して、GACアセンブリを参照する設定をおこなっても、`dotnet build` `dotnet pack` コマンドでは参照出来ない。 `msbuild` コマンドでのみ利用可能。 ::: ## グローバルアッセンブリが格納されたフォルダを`AssemblySearchPaths` に指定することで、dotnet build` `dotnet pack` コマンドでも参照可能になる。 ```xml= <PropertyGroup> <AssemblySearchPaths> $(AssemblySearchPaths); C:\Program Files (x86)\XXXXXXXX\Bin\v9.9; </AssemblySearchPaths> </PropertyGroup> ``` ## SDKスタイルのプロジェクトで、`AssemblySearchPaths`に設定されている内容 https://hackmd.io/heLCudSKRY2bGatU3Qm-lw ```xml= <AssemblySearchPaths> {CandidateAssemblyFiles}; {HintPathFromItem}; {TargetFrameworkDirectory}; {RawFileName}; </AssemblySearchPaths> ``` ###### tags: `MSBuild` `SDK Style` `GAC assemblies`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up