$(SolutionDir) is blank for a Visual Studio 2022 C# project when using it in any Preferences text box

I am following a tutorial online using PInvoke in order to call into a C++ native .dll. All things seem to be working properly, until I get to a point where I need to set the Base Output Dir for the build artifacts in the Properties page of the C# project.

As you can see here, the path doesn’t show $SolutionDir, it is blank

When I try to use it in Post Build Events, it is also telling me that this is an undefined value.
At the end of the build there is an undefined showing

I can use pretty much any other macro such as $(Configuration) $(Platform), etc, but $(SolutionDir) just will not work. Has this been removed as supported recently?

My Visual Studio version is
Microsoft Visual Studio Professional 2022 (2) (64-bit) – Current
Version 17.11.4

I tried using this macro first in the Base Output Directory, and then when that didn’t work, I tried to use it in a script within the Events section and tried doing a copy ($SolutionDir)file command to the output directory I want to use. But no matter where I try to use $(SolutionDir), it does not work.

I would expect to the solution dir to expand to the directory of the solution’s directory path.
Interestingly, this path DOES seem to work in the C++ project properties page:

Using $(SolutionDir) in C++ project

When I build the C++ project, this path is working:

The output path is getting resolved correctly here to the path of my solution file.

5

For those interested in a workaround, I found the following way to do this. If you edit your C# .proj file and use it as an item to copy to the output path afterwards this appears to work.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><ItemGroup>
<Content Include="..NativeLibrarybin$(Platform)$(Configuration)NativeLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</code>
<code><ItemGroup> <Content Include="..NativeLibrarybin$(Platform)$(Configuration)NativeLibrary.dll"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> </code>
<ItemGroup>
  <Content Include="..NativeLibrarybin$(Platform)$(Configuration)NativeLibrary.dll">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

Thanks to the provider for this answer: Are there any better ways to copy a native dll to the bin folder?

But still, it would be good to know why SolutionDir can’t be accessed in any build events.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật