roslyn: Solution.AddAdditionalDocument does not add a new file with AdditionalFiles item type

When adding a new file to a solution from within a codefix provider using the Solution.AddAdditionalDocument method, the file gets added with an item type of None where an item type of AdditionalFiles is expected.

This issue was observed using VS2015 RTM with roslyn 1.0.0

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 9
  • Comments: 31 (15 by maintainers)

Most upvoted comments

Rather than try to change the nupkg so that AdditionalItems is used instead of None, why not just change how stylecop.json is found like some other tools (including NuGet) that search up from the project directory looking for it? That way, we can put a single stylecop.json in the solution root and all projects will use it automatically. If a project wants to override, have a project-local copy with changes. Lots of tools work this way, like git with .gitignore.

5 years passed, any updates? This issue is critical if you want to add your own configuration files from the Roslyn-based extension.

Bumped into the same issue. Any news on that?

@GarretWayne You’re always welcome to contribute. I’ll add the tag as well, but it’s not a requirement for that.

@GarretWayne this is in the backlog currently. If you are interested in fixing it though we would certainly take a community contribution. Thanks!

Can you add the “up for grabs” tag, please?

Any progress or update?

I was having this problem with the example CodeAnalyzer project and installing the analyzers I had made via nuget package. After wading through quite a few other project template related difficulties, I was able to get this to work by updating the nuget install.ps1 (that project template needs cleanup) to include the following at the end…

$item = $project.ProjectItems.Item("ForbiddenReferences.xml") 
$item.Properties.Item("BuildAction").Value = 4  

4 is the magic BuildAction for “AdditionalFiles”, and it didnt require a project reload.

I’m not sure if this is useful to anyone, but going through this thread helped me get to this solution.