MSBuild:OutputPath目录为空 [英] MSBuild: OutputPath directory is empty

查看:324
本文介绍了MSBuild:OutputPath目录为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想部署我的ASP.NET MVC网站。
我有下一个脚本。


 < Import Project =.. \MyProjName\MyProjName.csproj/> 

< PropertyGroup>
< NewInstallDir> C:\DeployFolder\< / NewInstallDir>
< BinDir> $(NewInstallDir)bin\< / BinDir>
< / PropertyGroup>

< Target Name =Build>
< MSBuild Projects =.. \MySlnName.sln
属性=Configuration = Release; Platform =任何CPU; OutputPath = $(BinDir)/>
< Copy SourceFiles =@(Content->'.. \MyProjName\%(RelativeDir)%(FileName)%(Extension)')
DestinationFiles =@(Content- >'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')/>
< Copy SourceFiles =@(None->'.. \MyProjName\%(RelativeDir)%(FileName)%(Extension)')
DestinationFiles =@ >'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')/>
&MakeDir Directories =@(Folder->'$(NewInstallDir)%(RelativeDir)')/>
< / Target>



主要想法。 >我将二进制文件复制到C:\DeployFolder(从源文件夹结构)
我将我的dll建立到C:\DeployFolder\Bin(在源文件夹中没有这个文件夹,所以我需要分开复制这个)。
我运行我的脚本 - 所有的工作,而不是复制dll的OutputPath。
相同的脚本适用于其他asp.net mvc项目。
不知道在这种情况下有什么问题。
我完成这个问题与解决方法,但我想知道这个脚本有什么问题。

解决方案

我会尝试的第一件事是以$(OutDir)替换您弃用的$(OutputPath)的使用。从我看到这个错误的时候,10点中的9次是由于要求的平台/配置与实际定义的特定项目之间的不匹配。注意跟踪解决方案文件所偏好的任何CPU(有空格)和$(Platform)项目文件中实际使用的AnyCPU之间的差异。一些项目向导只设置一个x86平台,或者以其他方式省略可以导致OutputPath为空的AnyCPU。



除此之外,导入项目的方法文件,然后构建一个解决方案(可能包括相同的项目有点偏离中心,考虑通过导入在项目文件本身中进行所需的部署更改,您可以将它们连接到右侧的现有构建目标或者添加额外的目标。


I want to deploy my ASP.NET MVC site. I have next script.

<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>

Main idea.
I copy 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 dll's to OutputPath.
Same scripts works for other asp.net mvc project.
No idea what wrong in this case.
I complete this issue with workaround but I want to know what wrong with this script.

解决方案

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.

这篇关于MSBuild:OutputPath目录为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆