Unable to apply publish properties for item X

C#Visual Studio-2010Visual StudioVisual Studio-2012Clickonce

C# Problem Overview


Whenever we do a build in our main solution we receive the following warning:

> Unable to apply publish properties for item > "microsoft.visualstudio.qualitytools.unittestframework".

Has anyone seen anything like this before? Any ideas on how to fix this? It happens on all of our developer machines and also on our TFS build server as well. However, it only appears in Debug mode.

C# Solutions


Solution 1 - C#

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.

Solution 2 - C#

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJonathan NixonView Question on Stackoverflow
Solution 1 - C#Jonathan NixonView Answer on Stackoverflow
Solution 2 - C#Jirka HanikaView Answer on Stackoverflow