Skip to content

Build fails when properties are in platform-conditional PropertyGroups #13

@xXTurnerLP

Description

@xXTurnerLP

What happened?

When I open the ASM Viewer window it fails to compile the project and looking into the "show details" button it says dotnet failed to compile due to CSC : error SYSLIB1062: LibraryImportAttribute requires unsafe code. Project must be updated with '<AllowUnsafeBlocks>true</AllowUnsafeBlocks>', however the project already does have AllowUnsafeBlocks in the csproj and can be build perfectly fine with Rider

Relevant log output or stack trace

Steps to reproduce

I found that the issue triggers when you have the <AllowUnsafeBlocks>true</AllowUnsafeBlocks> placed in the configuration specific blocks in the csproj, if you place the AllowUnsafeBlocks attribute in the root one where it has no filters it will work properly

This triggers the issue:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

If you put it in the main one, it will work and build properly:

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <LangVersion>latest</LangVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
    <Configurations>Release;Debug</Configurations>
    <Platforms>x64</Platforms>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

DotNetDisassembler Plugin version

0.1.1

Rider version

2025.3.3

.NET SDK version

10.0.104

Operating System

Linux

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions