C# Custom Tool 'SettingsSingleFileGenerator' output not found - c#

I downloaded the source code for this JiraSVN plugin, and opened the .sln file in VS2010. I was immediately greeted by this warning:
A custom tool 'SettingsSingleFileGenerator' is associated with file
'Properties\Settings.settings', 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.
I'm not familiar at all with this custom tool or what it is supposed to do, nor how to resolve the problem. (I tried the suggestion to right-click and re-run the custom tool, but nothing happened.)
When I attempt to build, it fails with this error:
Source file 'C:...\Properties\Settings.Designer.cs'
could not be opened ('Unspecified error ')
Taking a look at the Solution Explorer, I see the following entry under one of the projects:
└─Properties
└─/!\ Settings.settings
└─/!\ Settings.Designer.cs
(where the last two entries have exclamation point warning icons.)
I tried to exclude those two entries from the project, but got many more errors.
How do I resolve this? Is the build broke, or have I just failed to set something correctly?

I suddenly encountered this same error while attempting to compile my own saved code. The code would no longer compile, even though the last time I had saved it, everything was fine.
I simply deleted "SettingsSingleFileGenerator" from the Custom Tool line of the properties of the Settings file (mine was in My Project/Settings folder, your error message should tell you where this is located). Removing this allowed me to compile again smoothly.

In the context menu of your project go to Properties - Settings - "Click here to create ...". This created an empty properties file which sufficed for my project.

Well, the build was indeed broken. There is a fork by PatrickMauer that reconstructs the missing files.

Open the .csproj file in a text editor and remove the LastGenOutput tag. Visual Studio thinks that there was some error during settings file generation if the LastGenOutput tag is present and keeps issuing a warning during build.
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings1.Designer.cs</LastGenOutput>
</None>

Related

Ambiguous reference intellisense error from Resource.Designer.cs

I am running into a peculiar bug when developing on Visual Studio 2017 that I have been able to ignore for a while, but is now beginning to really bug me.
I refer to this issue as a bug rather than an error because I am still able to build my projects in Visual Studio and deploy them to my development device without errors or warnings from the build output. This might seem alright to ignore for a bit, but over time it has become an issue because my intellisense is underlining it in red as an error
every time I reference attributes from the Resource class. As you might guess, I refer this class a lot and the Visual Studio editor eventually becomes cluttered with these "errors" which (a) hinders my ability to find actual errors in my code and (b) irritates me beyond all reason...
"Error" Investigation
As shown in the last image, intellisense is picking up an "Ambiguous Reference" to each attribute in the Resource class. When I check my Resource.Designer.cs file I only see one reference, but get a second error
.
It is now telling me that that a "Member with the same name is already declared". This lead me to believe that there is a second Resource.Designer.cs file, but my solution explorer and windows explorer both show only one.
Attempted solutions
Changed the namespace from InventoryApp (the default namespace of the file) to InventoryApp.Resources. This rid me of the ghastly errors but, upon building the project, it reverts the namespace in the file back to it's default, and the errors pop back up. I was also told by somebody who knows better that this is a big no-no.
Deleted the Resource.Designer.cs file, deleted the "obj" and "bin" folders from the project, cleaned and rebuilt the solution, then added the new Resource.Designer.cs file back to my solution. This did nothing to solve the problem.
Created an entirely new project from scratch. Even after creating a Blank Android App from the Visual Studio templates, the error persists. This begs the question: Is this a problem with my installation of Xamarin.Android?
Side-notes
The Resource.Designer.cs file's Build Action is set to "Compile"
The .csproj config file contains the tags:
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
6/6/2018 Update
If you have ReSharper, you most likely will be able to disregard my per-project solution described below and, instead, simply install the latest version (currently ReSharper 2018.1.2). Apparently, the underlying issue was caused by a bug in a previous version. Upgrading resolved the issue for me.
See youtrack.jetbrains.com/issue/RSRP-469636 for more information.
Thanks to #davidbauduin over at Xamarin Forums for this information.
I believe I have figured out the underlying issue and have a viable solution.
Solution
Add the following to the <PropertyGroup> section in your .csproj file:
<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
Reason
While previous versions of Visual Studio had that feature turned off by default, the latest VS2017 update (15.7.3) has it turned on. That feature generates a second Resources.Designer.cs file that results in the ambiguous reference issue.
You can verify by hovering over the resource constant with the Intellisense error, right-clicking, selecting "Go To Definition", and selecting the 1st item, which takes you to a Resource.Designer.cs file. If you repeat, but select the 2nd one, you'll be taken to a different Resource.Designer.cs file. One of these points to the obj\Debug\designtime\Resource.Designer.cs file. By setting that feature to False as described above, that Resource.Designer.cs file in the obj\Debug\designtime path will not be generated.
Information Regarding the AndroidUseManagedDesignTimeResourceGenerator Feature:
https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#design-time-builds-managed-resource-parser
https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#design-time-builds
Hope this helps!

Unable to create a manifest resource name for

I've made a git rebase from master on the branch I'm working and after that every time I try to build my project it doesn't, and is showing me an error message, actually is showing several error messages but I think they are related to this one:
Unable to create a manifest resource name for
Migrations\24534563454_SomeFile.resx. Could not find file
'SomePath\MyProject\Migrations\24534563454_SomeFile.cs'
I've restarted VS, clean my project and rebuild it but the error persists.. maybe this has to do with the .csproj file? What should I do?
Following the link suggested by #kennyzx in the comment and the responses on that link, I saw that there was a yellow warning icon in the file within the Migrations folder in the Solution Explorer. I deleted that file and now it built correctly

SpecFlow .feature.cs file gets duplicated when feature file is edited

When I edit Foo.feature, SpecFlow creates a new Foo1.feature.cs instead of overwriting Foo.feature.cs. The duplicated file then causes compile errors due to duplicated symbols.
It happens only for one of the .feature files in my project - all others behave normally. All the .feature and .feature.cs files are under source control and added to the Foo.csproj file.
I think I found the problem - in my .csproj file I had this entry:
<None Include="Foo.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Foo1.feature.cs</LastGenOutput>
</None>
I think the <LastGenOutput> was confusing SpecFlow. I don't know where it came from, but changing it to <LastGenOutput>Foo.feature.cs</LastGenOutput> fixed the issue.
Edit: I just found out that a missing <LastGenOutput> tag can also cause a duplicate Foo1.feature.cs file to be created. So if the tag is missing create it and put the correct filename in it.
After googling for SpecFlow and "LastGenOutput", I found this thread - https://groups.google.com/forum/#!topic/specflow/SpOihmvoAOQ. It outlines the same problem and solution:
Issue may be very annoying. Possible solution (do at you own risk!)
delete all YourFeature1.feature.cs files in Visual Studio. Save project.
close Visual Studio, open your .csproj file with notepad
find the lines similar to this one:
YourFeature1.feature.cs
change them to
YourFeature.feature.cs
save, load project in Visual Studio. Enjoy.
But you have to already know the solution in order to find that thread.

Source file in CSC cannot be found

After a struggle with creating a database (first with an entity framework, after without), we have a database (and an EntityModel_HFFContext file we don't use, it's not connected). Normal work proceeded, and I installed a NuGet-package for an MVC sitemap.
From that moment, the project worked fine, but after a couple of days two warnings came up about two files missing: "The parent file, 'EntityModel_HFF.tt', for file 'locatie.cs' cannot be found in the project file." ("HFF" is the project name in here) and then those multiplied themselves into errors: "Source file 'locatie.cs' cannot be found" in a CSC file I cannot find.
These two files ('locatie.cs' and 'klant.cs') are not in any view, but somehow they are displayed outside all folders, saying they do not excist (see this screencapture). I have tried to delete those files manually, but that did not have any success. I have tried some other ways too, but that resulted into the complete deletion of the database, so now I am somewhat desperate.
I have no idea where to look and what to do, to get rid of these two files (or probably references to these files, since we don't use them at all), so I don't have these errors anymore. Has anyone of you have a clue of where I need to look (e.g. where this CSC file is) and what I need to adjust to fix this?
Maybe it can be useful to know I use Visual Studio 2013.
Update
I fixed the errors by unloading the project, editing the .csproj file and commenting out
<Compile Include="klant.cs">
<DependentUpon>EntityModel_HFF.tt</DependentUpon>
</Compile>
(and the other one too). Now these errors are gone - is this a safe way to do this?
The reason why you get the error is because when you deleted the locatie.cs and klant.cs file, you didn't remove them from the project solution itself, therefore, Visual Studio is expecting the file to be part of the project but is unable to find them, which explains the yellow warning signs.
Like what you said, all you have to do is to remove the files from the solution as they no longer exists. So yes, it is safe to comment out that portion in the .csproj file.
Although, I would like to mention that you didn't have to go to that much trouble, all you had to do was to delete the file in your solution in Visual Studio, since they no longer exists anyway.

File and Line Numbers for Errors are not Displaying in the Error List Unless the File Is Open

I have a solution where the file name and line number of the error isn't displaying in the Error List, unless I have the file open.
I have another solution where just three errors show up when I build the solution, and they do display the line number and file. If I open the file with the error, another 3 errors pop up, but when I close the file, all the errors disappear until I rebuild again.
The only issue I've seen from googling is that the path is too long or too weird, but I don't think this is an issue. Path is C:\TFS\Apps\Rel_2013.7.1\S3\CrmSvcUtil Extensions for the solution that is partially working and C:\TFS\Apps\Rel_2013.7.1\S3 for the one that doesn't work at all.
Edit 1
Just to make it clear what I'm seeing: I have multiple projects in my solution but one of them doesn't show the file or line number of the error unless the file is open.
In this screen shot I've added two dumb errors, each in a different project, and have built the solution. The Test Project displays the file and line number as expected. The Common project isn't displaying the file or line number error even though it should and does when I actually open the file with the error in it. The Warning isn't displaying the file because it is a project level warning, not a file level warning, this makes sense.
When I open the file with the error the file name and the line number do show up, but on a different error:
If I change the int to a string, only the line numbered error is removed. I actually have to build in order for the error to be removed.
I had the same issue on projects that are using legacy Workflow framework V3. Interesting to note, that if project has only compiler warnings, the file and line are shown correctly, but error causing all warnings and errors refer to file C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.Targets(121,5):
The nasty workaround that I found is
Unload the project
Comment out at the bottom of the .csproj file the line
<Import Project="$(MSBuildToolsPath)\Workflow.Targets" />
Reload the project and compile it. Compiler errors will be shown with correct file name and line numbers.
Fix compiler errors
Again unload the project, restore Workflow.Targets import and reload the project.
The similar solution was reported to MS https://connect.microsoft.com/VisualStudio/feedback/details/797056/state-machine-workflow-projects-using-vs-2012
If you forget to restore Workflow.Targets import, there will be run-time errors like
System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation.
at System.Workflow.Runtime.WorkflowDefinitionDispenser.ValidateDefinition(Activity root, Boolean isNewType, ITypeProvider typeProvider)
at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity
Certain errors such as schema errors are reported but don't affect the final build. Depending on the file you may/may not see errors unless the file is open. Here are some things to try
Build in debug/release mode and see if that changes things for either build.
Change the MSBuild Project Build Output Verbosity (Tools-> Projects & Solutions -> Build and Run) to see if that has an effect. I surmise that will only add to the output but not affect on the Error List Window.
Does this happen in VS2013? That might provide a clue.
It is not unusual there to be differences between output builds and intellisense errors as reported.
Sounds to me like you are just looking at errors that are generated by the IntelliSense parser. Which only looks at open files. When you close the file then those IS errors will be removed from the list again. Seeing the error list change after you've built and open a file is similarly explained, the IS parser takes over again.
This is all by design, get ahead by just fixing the errors.
Michaels solution didn't work for us in May, 2018.
Visual Studio 2017 + .NET 4.7.2, and C# 7.2, old Workflow service.
It was inline variable declerations added:
int.TryParse(s, out int queueId);
Went back to pre-defining variables and it compiled successfully.
int queueId = 0;
int.TryParse(s, out queueId);
I would ascertain Microsoft has a bug.
Sample Errors:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : Invalid expression term 'int'
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : ; expected
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : Invalid expression term ')'

Categories

Resources