Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build Visual F# Tools tools with build vs, MSB4066 "GenerateSource" is unrecognized. #3638

Closed
abelbraaksma opened this issue Sep 24, 2017 · 6 comments · Fixed by #3635

Comments

@abelbraaksma
Copy link
Contributor

abelbraaksma commented Sep 24, 2017

I receive the following error on 13 projects:

VisualFSharp\vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj(32,52): error MSB4066: The attribute "GenerateSource" in element is unrecognized.

Repro steps

In my case, following the instructions in DEVGUIDE.md and just running build vs got me this error. I though perhaps I needed to downgrade to MSBUILD 12 as mentioned there are a prerequisite, but that didn't change anything.

Note that build (without params) just works. It fails with build vs.

Expected behavior

Build should just succeed.

Actual behavior

Error as mentioned.

Here's a full log in case that will shed some more light on this: build_vs.log

Known workarounds

None so far

Related information

It seems like my system does not contain the build task to generate sources from resx files anymore. However, I have several projects that do generate sources. I've reinstalled MSBUILD and have yet to find out where this task is located and/or why it is failing to recognize this. Google gave zilch.

@majocha
Copy link
Contributor

majocha commented Sep 24, 2017

@abelbraaksma IIRC I did build proto and then build vs and got it fixed.

@realvictorprm
Copy link
Contributor

I usually take a fresh copy and then run always in administrator mode (in the VS developer command prompt) just

build.cmd vs

@abelbraaksma
Copy link
Contributor Author

@majocha and @realvictorprm, thanks. It looks like there's a bug here:

IIRC I did build proto and then build vs and got it fixed.

That didn't help, neither did cleaning the copy, or rolling back to an older revision (though prior to #3607, a different error was logged).

and then run always in administrator mode

Indeed, and that's also in the DEVGUIDE.md, and if you don't, you will get E_ACCESS_DENIED errors from the ngen commands and registry changes for installing the vsix.

(in the VS developer command prompt)

That solved it! But then it's still a bug, as the DEVGUIDE.md specifically does not mention that and the build.cmd clearly contains code to find and execute VsDevCmd.bat (the batch file for any VS20XX installation to start the developer command prompt). That seems to be there so that it can be run from a "normal" commandprompt (understandable, as that makes it easier to run it on build systems).

@abelbraaksma
Copy link
Contributor Author

In fact, this code should take care of that:

REM load Visual Studio 2017 developer command prompt if VS150COMNTOOLS is not set

REM If this is not set, VsDevCmd.bat will change %cd% to [USERPROFILE]\source, causing the build to fail.
SET VSCMD_START_DIR=%cd%

if "%VS150COMNTOOLS%" EQU "" if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" (
    call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
)
if "%VS150COMNTOOLS%" EQU "" if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" (
    call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
)
if "%VS150COMNTOOLS%" EQU "" if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" (
    call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
)
if "%VS150COMNTOOLS%" EQU "" if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" (
    call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"
)

And that's where the problem lies: it doesn't take into account that on some systems (like the one I am testing on) only a Preview edition is available. Unfortunately I cannot afford full licenses on all dev systems and VM's I use, and besides, it is probably even a good idea if some programmers run this with the most recent previews from time to time.

I'll turn this into a PR for a fix, hopefully @KevinRansom can have a look, as in #1782 he mentioned that the VS2017 RC is required:

vsix build requires VS 2017 RC and VSSDK to build. I added a check for this to the build.cmd file.

@KevinRansom: I couldn't immediately find the original PR for that (it's your comment ;) ), I should probably link that revision from a PR that fixes this.

Also, I am wondering: can you explain why there seems to be fallback code for VS2015, VS2012 in the build.cmd? As far as I can tell, that code will never hit, unless you don't have VS2017, but that should be turned into a requirement (I propose to add a check after the above lines, to make sure it's installed, and at the same time make those checks more rigorous in case it's installed on a different location).

@abelbraaksma
Copy link
Contributor Author

abelbraaksma commented Sep 24, 2017

In addition, this doesn't seem to be accurate anymore:

image

While it successfully builds from a VS2015 command prompt, that's only because build.cmd tries to find VsDevCmd.bat. It is precisely when it doesn't find it, that the build.cmd still thinks everything is OK, but downstream things start failing (in my case, I was lulled into thinking everything was fine because build worked, but only today found out that build vs didn't, because of this problem) (and @odytrice seems to have stumbled on the same issue: #3542 (comment))

To proof this, I just removed the lines from my previous comment, to ensure VS2017 is not found, as can be seen from this output snippet:

---------------- Done with arguments, starting preparation -----------------
VSSDKInstall:   D:\Projects\OpenSource\VisualFSharp\packages\Microsoft.VSSDK.BuildTools.15.0.26201\tools\vssdk
VSSDKToolsPath: D:\Projects\OpenSource\VisualFSharp\packages\Microsoft.VSSDK.BuildTools.15.0.26201\tools\vssdk\bin
VSSDKIncludes:  D:\Projects\OpenSource\VisualFSharp\packages\Microsoft.VSSDK.BuildTools.15.0.26201\tools\vssdk\inc
---------------- Done with prepare, starting package restore ----------------
All compilation targets are up to date.
All packages listed in packages.config are already installed.
All packages listed in packages.config are already installed.
All compilation targets are up to date.
All compilation targets are up to date.
---------------- Done with package restore, verify buildfrom source ---------------
---------------- Done with package restore, starting proto ------------------------
---------------- Done with proto, starting build ------------------------
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /nr:false /nologo build-everything.proj /p:Configuration=release  /p:BUILD_PUBLICSIGN=0
Build started 25-9-2017 1:14:18.

I.e., MSBuild\14.0 means VS2015's build. According to DEVGUIDE.md this should more than suffice, but that's not true anymore. I'll add a proposed fix to that text into the PR too.

I think it is important to have a smoothest-possible experience with the build, as in particular new committers may simply give up too soon after finding it doesn't work.

@realvictorprm
Copy link
Contributor

I can tell you, that it's pretty difficult to achieve finding the correct paths to Visual Studio 2017. I'll always recommend to use the developer command prompt instead of trying to fix this for hours.

@dsyme dsyme closed this as completed in 01eab69 Sep 25, 2017
KevinRansom added a commit that referenced this issue Oct 11, 2017
* Generate source for .resx files on build. (#3607)

* add build task to generate *.fs from *.resx files

* generate source for embedded resources in tests

* generate source for embedded resources in FSharp.Editor

* generate source for embedded resources in FSharp.LanguageService

* generate source for embedded resources in FSharp.ProjectSystem.FSharp

* generate source for embedded resources in FSharp.VS.FSI

* don't generate non-string resources when <=netstandard1.6

* update baseline error message for tests

The error output should be the exception message, not the exception type.

* perform up-to-date check before generating *.fs from *.resx

* remove non-idiomatic fold for an array comprehension

* correct newline replacement

* output more friendly error message

* throw if boolean value isn't explicitly `true` or `false`

* only generate object resource code on non `netstandard1.*` and `netcoreapp1.*` platforms

* ensure FSharp.Core specifies a target framework for resource generaton

* rename attributes to be non-ambiguous and properly include them

* fix order of file items in FSharp.Core

* Fix build.cmd for certain always-shown errors (like "unable to find registry key"), improve finding of VS2017 tools, fix DEVGUIDE.md (#3635)

* Fix build.com displaying the following error on each run "ERROR: The system was unable to find the specified registry key or value."

* Remove warning about reg.exe errors introduced in #3614 (in commit b548bd7, but unrelated to that fix), it is no longer necessary.

* Fix #3638, VS2017 Preview installation was not found when VS2017RTM is not installed. Remove comment introduced in #3614 (through commit 966bd7f)

* Fixing JaroWinkler tests with InvariantCulture and fixing async tests by removing Debugger.Break() (#3627)

* Fixing JaroWinkler tests to use InvariantCulture for number-to-string

* Fixing the crashing of test runners because of a Debugger.Break() in a test

* update to System.Collections.Immutable 1.3.1 (#3641)

* update to System.Collections.Immutable 1.3.1

* fixes

* fix assembly reference

* [WIP] Adds optimized emit for int64 constants (#3620)

* Adds optimized emit for int64 constants.

* Adds comment linking to the changing PR.

Thanks for this PR.

Kevin

* fix assembly reference (#3646)

* Remove a few more build warnings (#3647)

* fix assembly reference

* remove more build warnings

* fix build

* move BuildFromSource projects to their own directory

* Adds tests for emitted IL for new Int64 constants. (#3650)

* Enable FS as prefix and ignore invalid values for warnings (#3631)

* enable fs as prefix and ignore invalid values for warnings + tests

* Allow #pragma to validate warnings

* do it right

* use ordinal compare

* In both places

* Add fs prefix to warnaserror

* Fixup tests

* Fix stack overflow on assembly resolution (#3658)

* Fix stack overflow on tp assembly resolution

* Feedback

* Add impl files to file check results (#3659)

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project

* add ImplementationFiles to FSharpCheckFileResults

* make FSharpImplementationFileContents ctor internal

* throw if ImplementationFiles is called having keepAssemblyContents flag set to false

* add a test

* spelling and cosmetics

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd (#3672)

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* Remove ambiguous an irrelevant instruction, improved help and instructions

* Fix a scenario where the return code wasn't nonzero for error conditions, fixes not creating backup dir when not backing up

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project (#3657)

* bump FCS version (#3676)

* bump version

* Update RELEASE_NOTES.md

* Parsing improvements: no reactor, add parsing options, error severity options (#3601)

* Parse without reactor, add parsing options, error severity options

* Revert parsing APIs (fallback to the new ones), fix VFT projects

* Cache parse results after type check

* Add impl files to file check results (#3659)

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project

* add ImplementationFiles to FSharpCheckFileResults

* make FSharpImplementationFileContents ctor internal

* throw if ImplementationFiles is called having keepAssemblyContents flag set to false

* add a test

* spelling and cosmetics

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd (#3672)

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* Remove ambiguous an irrelevant instruction, improved help and instructions

* Fix a scenario where the return code wasn't nonzero for error conditions, fixes not creating backup dir when not backing up

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project (#3657)

* bump FCS version (#3676)

* bump version

* Update RELEASE_NOTES.md

* updates to make tests pass

* restore old behaviour of CheckFileInProjectAllowingStaleCachedResults (builder had been created by ParseFileInProject)

* restore use of CheckFileInProjectAllowingStaleCachedResults

* deprecate test relying on whacky behaviour of deprecated GetCheckResultsBeforeFileInProjectEvenIfStale

* Use ParseFile and FSharpParsingOptions instead of ParseFileInProject

* prepare FCS release with this feature

* whitespace cleanup (#3682)

* whitespace and docs (#3684)

* Preserve XML docs for in-memory project references (#3683)

* fix xmldocs for in-memory project references

* add test

* fix tests

* whitespace and comments (#3686)

* fix assembly reference

* whitespace and comments

* whitespace and comments

* whitespace and comments

* cherry pick two PRs from FCS (#3687)

* fix assembly reference

* remove line endings from all *.nuspec files

* ProjectCracker returns *.fsi files in FSharpProjectOptions.SourceFiles array (in addition to *.fs files, in right order)

* ProjectCracker raises exception if ProjectCrackerTool returns non null ProjectCrackerOptions.Error (new field)

* fix build on linux

* fix a test

* slashes

* revert slashes

* Update FSharp.Compiler.Service.ProjectCracker.nuspec

* try to fix travis

* try to fix travis

* list dependencies

* no obsolete pdb in nuget

* list dependencies

* cherry pick of fsharp/fsharp change

* bump FCS version number (#3688)

* Update FSharp.Compiler.Service.MSBuild.v12.nuspec

* fix FCS nuget on windows

* fix-resource (#3690)

* Bump FSharp.Compiler.Tools to 4.1.27 and align mono build files (#3693)

* ri change from fsharp

* fix test

* bump FSC tools to 4.1.27

* remove fsharp.core from Mono GAC

* align mono directory

* fix typo

* install back versions with Mono

* fix typo

* update FCS doc generation (#3694)

* update DEVGUIDE to add addiitional steps before running build (#3725)

* Split templates out into a seperate vsix (#3720)

* merge error

* Merge issues
nosami pushed a commit to xamarin/visualfsharp that referenced this issue Jan 26, 2022
* Generate source for .resx files on build. (dotnet#3607)

* add build task to generate *.fs from *.resx files

* generate source for embedded resources in tests

* generate source for embedded resources in FSharp.Editor

* generate source for embedded resources in FSharp.LanguageService

* generate source for embedded resources in FSharp.ProjectSystem.FSharp

* generate source for embedded resources in FSharp.VS.FSI

* don't generate non-string resources when <=netstandard1.6

* update baseline error message for tests

The error output should be the exception message, not the exception type.

* perform up-to-date check before generating *.fs from *.resx

* remove non-idiomatic fold for an array comprehension

* correct newline replacement

* output more friendly error message

* throw if boolean value isn't explicitly `true` or `false`

* only generate object resource code on non `netstandard1.*` and `netcoreapp1.*` platforms

* ensure FSharp.Core specifies a target framework for resource generaton

* rename attributes to be non-ambiguous and properly include them

* fix order of file items in FSharp.Core

* Fix build.cmd for certain always-shown errors (like "unable to find registry key"), improve finding of VS2017 tools, fix DEVGUIDE.md (dotnet#3635)

* Fix build.com displaying the following error on each run "ERROR: The system was unable to find the specified registry key or value."

* Remove warning about reg.exe errors introduced in dotnet#3614 (in commit b548bd7, but unrelated to that fix), it is no longer necessary.

* Fix dotnet#3638, VS2017 Preview installation was not found when VS2017RTM is not installed. Remove comment introduced in dotnet#3614 (through commit 966bd7f)

* Fixing JaroWinkler tests with InvariantCulture and fixing async tests by removing Debugger.Break() (dotnet#3627)

* Fixing JaroWinkler tests to use InvariantCulture for number-to-string

* Fixing the crashing of test runners because of a Debugger.Break() in a test

* update to System.Collections.Immutable 1.3.1 (dotnet#3641)

* update to System.Collections.Immutable 1.3.1

* fixes

* fix assembly reference

* [WIP] Adds optimized emit for int64 constants (dotnet#3620)

* Adds optimized emit for int64 constants.

* Adds comment linking to the changing PR.

Thanks for this PR.

Kevin

* fix assembly reference (dotnet#3646)

* Remove a few more build warnings (dotnet#3647)

* fix assembly reference

* remove more build warnings

* fix build

* move BuildFromSource projects to their own directory

* Adds tests for emitted IL for new Int64 constants. (dotnet#3650)

* Enable FS as prefix and ignore invalid values for warnings (dotnet#3631)

* enable fs as prefix and ignore invalid values for warnings + tests

* Allow #pragma to validate warnings

* do it right

* use ordinal compare

* In both places

* Add fs prefix to warnaserror

* Fixup tests

* Fix stack overflow on assembly resolution (dotnet#3658)

* Fix stack overflow on tp assembly resolution

* Feedback

* Add impl files to file check results (dotnet#3659)

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project

* add ImplementationFiles to FSharpCheckFileResults

* make FSharpImplementationFileContents ctor internal

* throw if ImplementationFiles is called having keepAssemblyContents flag set to false

* add a test

* spelling and cosmetics

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd (dotnet#3672)

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* Remove ambiguous an irrelevant instruction, improved help and instructions

* Fix a scenario where the return code wasn't nonzero for error conditions, fixes not creating backup dir when not backing up

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project (dotnet#3657)

* bump FCS version (dotnet#3676)

* bump version

* Update RELEASE_NOTES.md

* Parsing improvements: no reactor, add parsing options, error severity options (dotnet#3601)

* Parse without reactor, add parsing options, error severity options

* Revert parsing APIs (fallback to the new ones), fix VFT projects

* Cache parse results after type check

* Add impl files to file check results (dotnet#3659)

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project

* add ImplementationFiles to FSharpCheckFileResults

* make FSharpImplementationFileContents ctor internal

* throw if ImplementationFiles is called having keepAssemblyContents flag set to false

* add a test

* spelling and cosmetics

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd (dotnet#3672)

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* This adds backup, restore, coloration and many more checks to the update-vsintegration.cmd

* Remove ambiguous an irrelevant instruction, improved help and instructions

* Fix a scenario where the return code wasn't nonzero for error conditions, fixes not creating backup dir when not backing up

* add LanguageServiceProfiling project to internals visible to list of FSharp.Compiler.Private project (dotnet#3657)

* bump FCS version (dotnet#3676)

* bump version

* Update RELEASE_NOTES.md

* updates to make tests pass

* restore old behaviour of CheckFileInProjectAllowingStaleCachedResults (builder had been created by ParseFileInProject)

* restore use of CheckFileInProjectAllowingStaleCachedResults

* deprecate test relying on whacky behaviour of deprecated GetCheckResultsBeforeFileInProjectEvenIfStale

* Use ParseFile and FSharpParsingOptions instead of ParseFileInProject

* prepare FCS release with this feature

* whitespace cleanup (dotnet#3682)

* whitespace and docs (dotnet#3684)

* Preserve XML docs for in-memory project references (dotnet#3683)

* fix xmldocs for in-memory project references

* add test

* fix tests

* whitespace and comments (dotnet#3686)

* fix assembly reference

* whitespace and comments

* whitespace and comments

* whitespace and comments

* cherry pick two PRs from FCS (dotnet#3687)

* fix assembly reference

* remove line endings from all *.nuspec files

* ProjectCracker returns *.fsi files in FSharpProjectOptions.SourceFiles array (in addition to *.fs files, in right order)

* ProjectCracker raises exception if ProjectCrackerTool returns non null ProjectCrackerOptions.Error (new field)

* fix build on linux

* fix a test

* slashes

* revert slashes

* Update FSharp.Compiler.Service.ProjectCracker.nuspec

* try to fix travis

* try to fix travis

* list dependencies

* no obsolete pdb in nuget

* list dependencies

* cherry pick of fsharp/fsharp change

* bump FCS version number (dotnet#3688)

* Update FSharp.Compiler.Service.MSBuild.v12.nuspec

* fix FCS nuget on windows

* fix-resource (dotnet#3690)

* Bump FSharp.Compiler.Tools to 4.1.27 and align mono build files (dotnet#3693)

* ri change from fsharp

* fix test

* bump FSC tools to 4.1.27

* remove fsharp.core from Mono GAC

* align mono directory

* fix typo

* install back versions with Mono

* fix typo

* update FCS doc generation (dotnet#3694)

* update DEVGUIDE to add addiitional steps before running build (dotnet#3725)

* Split templates out into a seperate vsix (dotnet#3720)

* merge error

* Merge issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants