本文介绍了ASPNETCOMPILER错误,无法加载程序集(仅在msbuild中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS2015和MSBuild 14.

I am using VS2015, and MSBuild 14.

我的解决方案有很多项目,但是其中三个是旧的ASMX网站. ASMX网站的项目"没有自己的项目文件,但在解决方案文件本身的XML中进行了详细说明.

My solution has many projects, but three of them are old ASMX web sites. The ASMX website "projects" don't have their own project files, but are detailed in the XML of the solution file itself.

该解决方案在Visual Studio中构建良好.

The solution builds fine inside Visual Studio.

但是,当我尝试使用MSBuild在命令行上进行构建时,我收到一条错误消息.这是我的MSBuild命令:

However, when I try to build on the command line with MSBuild, I am getting an error message. Here is my MSBuild command:

C:\> msbuild MySolution.sln /t:MyAsmxProject

所有依赖项目(大多数是c#类库)都是按照我期望的那样构建的.在运行msbuild的cmd窗口中有很多输出,直到我们通过msbuild进行以下操作为止:

All the dependent projects (mostly c# class libraries) are built as I would expect them to be. Lots of output to the cmd window in which msbuild is running, until we get to the following action by msbuild:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /MyAsmxProject 
    -p MyAsmxProject\ -u -f -d -fixednames Precompiled\MyAsmxProject\

整个事情在这里爆炸,并出现以下错误:

The whole thing bombs out here with the following error:

ASPNETCOMPILER : error ASPCONFIG: Could not load the assembly.
    The property 'assembly' must be a valid assembly.
    [C:\My\Long\Path\MySolution\MyAsmxProject.metaproj]

现在起初我不知道什么是"metaproj"文件,并且找不到该文件,但是我确实理解它是在内部创建的中间项目文件,因此msbuild可以在解决方案文件上运行.我发现如果设置环境变量,我可以看到metaproj文件:

Now at first I didn't know what a "metaproj" file was, and was unable to find that file, but I did understand it to be an intervening project file created internally so that msbuild could operate on solution files. I discovered that I could see the metaproj file if I set the environment variable:

set MSBuildEmitSolution=1

然后重新运行msbuild命令.现在,对于我的解决方案和我的asmx项目,我都有metaproj文件,这似乎是上面错误消息中引用的文件.

And then re-ran the msbuild command. I now have metaproj files for both my solution and for my asmx project, which would appear to be the one referenced in the error message above.

这两个都是非常密集的msbuild文件,但是它们都没有一个名为"assembly"的XML节点(元素),并且它们都没有具有应用于其属性或属性"assembly"的XML节点.

These are both pretty dense msbuild files, but neither one of them have an XML node (element) named "assembly" and neither one of them have any XML nodes with the attribute or property "assembly" applied to them.

因此,我不清楚该错误在说什么以及如何解决.而且,为什么使用msbuild而不是使用Visual Studio的原因还不清楚.

So I am unclear what this error is saying and how to fix it. And doubly unclear as to why it crops up with msbuild, but not with visual studio.

任何见解或建议都值得赞赏.

Any insights or suggestions most appreciated.

推荐答案

尽管我不完全理解为什么,但是我找到了解决方案.

Although I don't fully understand why, I have found a solution.

也就是说,如果我以管理员身份运行msbuild的命令窗口,则不会出现此错误.这是我可以接受的解决方案.

Namely, if I run the command window in which I am doing the msbuild as an administrator, I don't get this error. This is an acceptable solution for me.

但是....仍然很高兴能更具体地了解错误的含义以及为什么成为管理员会有所作为.

However.... it would still be great to understand more specifically what the error means, and why being an adminstrator makes the difference.

这篇关于ASPNETCOMPILER错误,无法加载程序集(仅在msbuild中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 23:09