Custom Build Step Paths Between x86 and x64 in Vis

2019-07-04 00:56发布

For reference, I'm using Visual Studio 2010.

I have a custom build step defined as follows:

if exist "$(TargetDir)"server.dll copy "$(TargetDir)"server.dll "c:\program files (x86)\myapp\server.dll"

This works great on my desktop, which is running 64-bit Windows. However, when I build on my laptop, c:\Program Files (x86)\ doesn't exist because it's running 32-bit Windows. I'd like to put in something that will work between both editions of Windows, since the project files are under version control and it's a real pain to change the paths every time I work on my laptop.

If this were a *nix environment I'd just create a symlink and be done with it. Any ideas?

1条回答
我只想做你的唯一
2楼-- · 2019-07-04 01:36

You can put this in your project file:

 <PropertyGroup>
    <ProgramFiles32 Condition="Exists('$(PROGRAMFILES) (x86)')">$(PROGRAMFILES) (x86)</ProgramFiles32>
    <ProgramFiles32 Condition="$(ProgramFiles32) == ''">$(PROGRAMFILES)</ProgramFiles32>
  </PropertyGroup>

And then you can use $(ProgramFiles32) in your post build event.

For more information check this stackoverflow question.

查看更多
登录 后发表回答