MSBuild: OutputPath directory is empty

≯℡__Kan透↙ 提交于 2019-12-24 00:56:48

问题


I want to deploy my ASP.NET MVC site and have the following script.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\MyProjName\MyProjName.csproj"/>
  <PropertyGroup>
    <NewInstallDir>C:\DeployFolder\</NewInstallDir>
    <BinDir>$(NewInstallDir)bin\</BinDir>
  </PropertyGroup>
  <Target Name="Build">
    <MSBuild Projects="..\MySlnName.sln"
        Properties="Configuration=Release;Platform=Any CPU;OutputPath=$(BinDir)" />
    <Copy SourceFiles="@(Content->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
        DestinationFiles="@(Content->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
    <Copy SourceFiles="@(None->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
        DestinationFiles="@(None->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
    <MakeDir Directories="@(Folder->'$(NewInstallDir)%(RelativeDir)')" />
  </Target>
</Project>

Main idea.

I copied binary to C:\DeployFolder (take structure of folder from sources). I build my dll to C:\DeployFolder\Bin (I don't have this folder in sources folder so I need separately copy this).

I run my script - all works instead of copy DLLs to OutputPath. Same scripts works for other asp.net mvc project. I have no idea what is wrong in this case.

I complete this issue with workaround but I would like to know what is wrong with this script.


回答1:


The first thing I'd try is to replace your use of the deprecated $(OutputPath) with $(OutDir). From when I've seen this error, 9 times out of 10 it is due to a mismatch between the Platform/Configuration requested and how a particular project is actually defined. Take care to keep track of the discrepency between "Any CPU" (with a space) preferred by solution files and "AnyCPU" actually used inside project files for $(Platform). Some project wizards only set up an "x86" Platform or otherwise omit "AnyCPU" which can cause the OutputPath to be empty.

Beyond that, the approach of importing a project file and then building a solution (presumbably that includes the very same project" is a bit off center. Consider making the deployment changes you desire within the project file itself, through an import. You can either wire into the existing build targets at the right place, or perhaps add an additional target.



来源:https://stackoverflow.com/questions/5960800/msbuild-outputpath-directory-is-empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!