在ASP.NET核心3.1应用程序中,obfuscar.xml中给定的路径是正确的,但是无法找到程序集/无法解析程序集
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value=".\bin\Debug\netcoreapp3.1" />
<Var name="OutPath" value="$(InPath)\publish" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="HideStrings" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="SuppressIldasm" value="true" />
<Module file="$(InPath)\Sample.dll" />
</Obfuscator>生成错误:
4>Note that Rollbar API is enabled by default to collect crashes. If you want to opt out, please run with -s switch
4>Loading project .\obfuscar.xml...
4>An error occurred during processing:
4>Unable to find assembly: .\bin\Debug\netcoreapp3.1\Sample.dll
4>Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
4>G:\SomePath\Sample.csproj(110,5): error MSB3073: The command "if Debug == Debug obfuscar.console .\obfuscar.xml" exited with code 1.
4>Done building project "Sample.csproj" -- FAILED.发布于 2020-08-06 18:23:07
这个组合在netcoreapp3.1上对我有效。
构建命令
确保使用publish以及--self-contained和-r来确保将所有必要的依赖项复制到输出目录。
dotnet publish -c Release --self-contained=true -r win-x64 <project.csproj>project.csproj
<ItemGroup>
<Content Include="obfuscar.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Obfuscar">
<Version>2.2.14</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>$(Obfuscar) obfuscar.xml</PostBuildEvent>
</PropertyGroup>Obfuscar.xml
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="." />
<Var name="OutPath" value=".\Obfuscator_Output" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="HideStrings" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="SuppressIldasm" value="true" />
<Module file="$(InPath)\Project.dll" />
</Obfuscator>发布于 2021-11-13 11:53:46
使用
<AssemblySearchPath path="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.5" />https://stackoverflow.com/questions/63050438
复制相似问题