سؤال

I have some csproj files which build as AnyCPU which ship with some native components which build for specific architectures. These files need to be placed in the same location, so I wanted to set the output directory according to the currently selected platform and configuration:

<PropertyGroup>
  <OutputPath>$(SolutionDir)\bin\$(Configuration)_$(Platform)\</OutputPath>
</PropertyGroup>

Unfortunately, because this is in the AnyCPU project, instead of this producing an output directory of $(SolutionDir)\bin\Release_x64\, it is producing an output directory of $(SolutionDir)\bin\Release_AnyCPU.

I would like to avoid making new bitness-specific versions of this library. I just want the builds to place the files in the right place.

How can the csproj know what the platform is for the overall build?

هل كانت مفيدة؟

المحلول

The $(Platform) value is completely irrelevant to a managed project. It does not in any way affect the way the project is built nor the way it runs. It is the jitter that determines the architecture, that happens at runtime, not build time.

The only setting that has any effect is Project + Properties, Build tab, Platform target. The value of this setting is not determined by $(Platform). This has caused an enormous amount of confusion since VS2010.

You should see the solution by now, since the platform name doesn't matter, you can simply make it the same as the platform name for your C++ projects. Add a x64 and Win32 configuration to the managed projects, if necessary. And delete the AnyCPU configuration since you don't need it anymore. Built + Configuration Manager to make sure that all project use the same Platform. Problem solved.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top