无法为项 X 应用发布属性

每当我们在主要解决方案中进行构建时,都会收到以下警告:

无法为项应用发布属性 “ microsoft.visalstudio.qualitytools.unittestFramework”。

以前有人见过这样的东西吗?有办法解决吗?它发生在我们所有的开发人员机器上,也发生在我们的 TFS 构建服务器上。但是,它只在调试模式下出现。

18940 次浏览

It appears that the issue is related to ClickOnce. Navigate to the project, right click on it and click on properties. Go to the Publish tab and click on Application Files. Check the 'Show all files' checkbox and scroll through the list of files. Eventually, you will come across the file that has a yellow exclamation point on it. This file is orphaned and needs to be removed. Right click on the file and there should be a remove option.

Now build the solution and the warning should be gone.

The top voted answer is perfect as it stands, but those of us dealing with larger outbursts may benefit from this alternative answer. It describes an analogous fix on file level.

The warning is caused by an element like this:

<PublishFile Include="THIS IS USUALLY SOME IMAGINARY DLL">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>

...in the project file (.csproj) emitting the warning. Notice the PublishState "Exclude"; this element says "please don't publish the imaginary DLL"; this is obviously a needless instruction if no such DLL is anywhere around at publish time, but it is then also causing the warning because the publish process cannot evaluate the file's identity.

You can remove the entire PublishFile element for each deployment item mentioned in the warnings, as long as it has PublishState "Exclude". Do not mechanically remove every element with PublishState "Exclude", because if there was no warning about it, the file is probably available at publish time and it might end up published - which would be an unwanted product change as long as you only wanted to get rid of the warning.