I've programatically created a number of files. I want to add them to the visual studio project. I have a reference to the project (DTE.Project). When I execute the code below, I get an error message.
project.ProjectItems.AddFromFile(filename);
The error is
Exception at 'Expand' - 'Unable to add 'manage.txt'. A file with that name already exists.'
System.Runtime.InteropServices.COMException (0x80040400): Unable to add 'manage.txt'. A file with that name already exists.
at EnvDTE.ProjectItems.AddFromFile(String FileName)
When I wrap the call in a try-catch, the process runs to completion but non of the files are added to the project. I have to manually show hidden files and then include them in the project.
How do I add the file for this to work?
#ritcoder - sure:
I think this thread provides the solution for your question - Visual Studio macro: Find files that aren't included in the project?
Related
I'm implementing google OAUTH for a Xamarin application I have downloaded the google-services.json and placed it in Solutionname.Android in visual studio solution, when I click on the file google-services.json in properties under Build Action i do not see the option GoogleServicesJson, I believe I need to Rebuild the solution for this option to be available, when I rebuild in Visual Studio, I get the error below
Error Invalid file name: It must contain only [^a-zA-Z0-9_.]+. Solution.Android C:\Users\username\source\repos\SolutionFolder\Solution.Android\google-services.json
In renaming google-services.json to google_services.json solved the above error but introduced another error invalid file path 'C:\Users\username\source\repos\SolutionFolder\Solution.Android\obj\Debug\110\res\google_services.json'
In short: When building a VSIX project In Visual Studio 2015, the build process is attempting to load random files (such as icons, .config files, .targets file) as if they were .Net assemblies.
I am attempting to build a VSIX project that includes a referenced project template and a embedded wizard assembly. I've done the exact same thing previously with success, following the steps described at How to: Use Wizards with Project Templates.
This time, however, when I attempt to build the VSIX project I get bizarre errors such as the following:
Could not determine the FullName of the Assembly at "C:\Source\VSTS\Toolkits\v7\Web.Site\v7.2\packages\Microsoft.Net.Compilers.1.3.2\tools\csc.exe.config". Could not load file or assembly 'csc.exe.config' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Note, the compiler is trying to load a config file as if it were an assembly. In fact, I first got this error when it was attempting to load the icon file for the VSIX...as if it were an assembly. If I rename or remove the file in the error message and rebuild I just get the same error but with the next random not-an-assembly file that the compiler encounters.
Why is the compiler attempting to load random files as if they were assemblies? How can I make it stop so that I can actually build my VSIX project?
More info:
This error is thrown by the DetokenizeVsizManifestSource build step defined in Microsoft.VsSDK.targets:
<DetokenizeVsixManifestSource
InputFile="#(SourceVsixManifest)"
OutputFile="$(IntermediateVsixManifest)"
ResolvedReferences="#(_VsixManifestResolvedReferences)">
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</DetokenizeVsixManifestSource>
I had the same problem. It seems you can't add add an applciation to a VSIX. You need the project to output a dll and attach that.
If you need to attach an application try to do so as File not as Project.
I created a Visual Studio extension with a couple of item templates. Now, I want to include some code snippets as part of that extension. I followed Mads Kristensen's post about the subject. However, when I try to compile the project, I get this error:
Could not determine the FullName of the Assembly at "C:\path\to\file\keys.pkgdef". Could not load file or assembly 'keys.pkgdef' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I'm developing my extension using Visual Studio 2013.
I think I followed the post carefully, so I don't know what it's missing here.
Thanks!
You need to change properties of the keys.pkgdef file:
Build Action: Content
Copy to Output Directory: Do not copy
Include in VSIX: true
Anyone can help us here - we have been having this error for several months and had many a stab to remove it, but we still havnt figured out why its there or how to remove it. How is this warning resolved or removed?
Warning 351 A custom tool 'GlobalResourceProxyGenerator' is associated
with file 'App_GlobalResources\GridLocalization.bg-BG.resx', but the
output of the custom tool was not found in the project. You may try
re-running the custom tool by right-clicking on the file in the
Solution Explorer and choosing Run Custom Tool.
After checking out the csproj file and discussing it in the group, we came up with the following answer:
When the resources were added to the project they were added using the wizard. This wizard added the designer files also, so for each reasource file there was also a .designer file.
This was seen as something that was not needed for the language specific resources and the designer files were deleted.
However the csproj files maintained the custom tool reference.
Deleting this reference (to "GlobalResourceProxyGenerator") for each of these resource files removed the issue.
The issue is that Visual Studio 2010 does not automatically remove this tool reference when the designer files are removed manually, creating this warning.
In my case this was caused by a <LastGenOutput> entry in the csproj file that referred to a non-existent file. Removing that line got rid of the warning.
In Visual Studio 2017 I had the same issue with the following error
Warning A custom tool 'ResXFileCodeGenerator' is associated with file <snip name>, but the output of the custom tool was not found in the project.
Removing the reference to
<Generator>ResXFileCodeGenerator</Generator> within the resource file declaration, fixed the issue.
In VS 2019, I also fixed the error:
Warning A custom tool 'ResXFileCodeGenerator' is associated with file , but the output of the custom tool was not found in the project.
By removing the reference to ResXFileCodeGenerator
found within the project's " .csproj" file!
This question to which I already found the answer is posted here in case of someone else encounters it. I decided to post the Q&A here so that SO has something about this error, since I don't know if it's been here before.
This occured after an update of the .NET Framework. Before the update, everything compiled just fine! After the update, I could compile nothing!
The error message is:
Error 1 - Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0'.
This is a problem within Visual Studio 2005. This occurs after an update of the .NET Framework 2.0 and is due to project reference within a single solution.
For example, when you're writing a test library which will test your assembly within the same solution, you will most likely reference the project. Then, this error may occur.
To solve this error, simply reference the file binary of your project, either the DLL or the EXE within which resides the code you want to test. This is called a file reference.
Let's suppose we have two projects called:
Company.Project.ApplicationName;
Company.Project.ApplicationName.Tests.
When adding the reference to our Company.Project.ApplicationName project within our Company.Project.Application.Tests project, we can either use the Browse or the Project tab. When using the Project tab, you create a project reference. We don't want to use this if this error occurs. What we want to use is Browse, so that we can make a file reference.
Here's a link to the Microsoft Support Website that explains this issue.
You may receive a "Could not find file 'Microsoft.Windows.CommonLanguageRuntime" error message when you build a solution of a Visual Basic 2005 Windows Application project in Visual Studio 2005