Closed mraipsec-mra closed 1 year ago
@ravindraaditya , can you export your build definition from VSTS and attach the json.
The package is available on nuget.org: https://www.nuget.org/packages/Microsoft.VisualStudio.Azure.Fabric.MSBuild/1.6.4 What does your nuget restore task in VSTS look like? Are you using NuGet.org?
@dbreshears here is the file xyz-CI.zip
@NCarlsonMSFT yes you are right, we have already done this before.
"phases":[{"steps":[{"environment":{},"enabled":true,"continueOnError":false,"alwaysRun":false,"displayName":"Use NuGet 4.5.1","timeoutInMinutes":0,"refName":"NuGetToolInstaller1","task":{"id":"2c65196a-54fd-4a02-9be8-xyz","versionSpec":"0.","definitionType":"task"},"inputs":{"versionSpec":"4.5.1","checkLatest":"true"}},{"environment":{},"enabled":true,"continueOnError":false,"alwaysRun":false,"displayName":"NuGet restore","timeoutInMinutes":0,"refName":"NuGetCommand2","task":{"id":"xyz-d341-40d9-afcf-xyz","versionSpec":"2.","definitionType":"task"},"inputs":{"command":"restore","solution":"$(Parameters.solution)","selectOrConfig":"select","feedRestore":"","includeNuGetOrg":"true","nugetConfigPath":"","externalEndpoints":"","noCache":"true","packagesDirectory":"","verbosityRestore":"Detailed","searchPatternPush":"$(Build.ArtifactStagingDirectory)/.nupkg","nuGetFeedType":"internal","feedPublish":"","allowPackageConflicts":"false","externalEndpoint":"","verbosityPush":"Detailed","searchPatternPack":"/.csproj"**,"configurationToPack":"$(BuildConfiguration)","outputDir":"$(Build.ArtifactStagingDirectory)","versioningScheme":"off","includeReferencedProjects":"false","versionEnvVar":"","requestedMajorVersion":"1","requestedMinorVersion":"0","requestedPatchVersion":"0","packTimezone":"utc","includeSymbols":"false","buildProperties":"","verbosityPack":"Detailed","arguments":""}}
I think what is missing was restoring of nuget packages for .sfproj
Hi,
I'm getting this exact same issue as well. When I look at the existing Nuget Restore step (for sln) I noticed this error message:
: error : Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.4\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package.
: warning NU1503: Skipping restore for project 'D:\a\1\s\MyFolder\MySFProj.sfproj'. The project file may be invalid or missing targets required for restore. [D:\a\_temp\NuGetScratch\54wapxvf.z4w.nugetinputs.targets]
I thought maybe just adding a Nuget restore step for .sfproj would resolve it (I don't know if this is valid for an sfproj) but then get the following error:
2018-02-22T19:46:27.4707517Z ##[error]The nuget command failed with exit code(1) and error(Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.)
2018-02-22T19:46:27.4708192Z ##[error]Packages failed to restore
Would appreciate a resolution for this.
Assad
Make sure you delete the "ServiceFabricBackup" folder, which is created automatically when Visual Studio updates the .sfproj file. The contents of that folder were causing issues with MSBuild for my team.
@SamHard, I deleted the ServiceFabricBackup folders from my local file system (I had 4 of them), made a fake change in the solution and committed to kick off a new build and to my amazement, it worked. it makes no sense as to why it worked as the ServiceFabricBackup folders were on my local machine and they were not committed or at least I couldn't see them in the GIT repository in VSTS. Many thanks @SamHard.
Assad
: error : Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.4\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package.
I found this issue after upgrading the nuget package of Microsoft.VisualStudio.Azure.Fabric.MSBuild from 1.6.4 to 1.6.5. So I edited the sfproj (SF project file) and replaced all Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.4 to Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.5 and these error messages gone for all.
@kishorebarik26 , thanks for letting us know, we will look into what is going on when updating the package in VS and why it is not updating the .sfproj automatically, for now it seems manually editing the .sfproj file and updating all occurrences from 1.6.4 to 1.6.5 would be the workaround.
@kishorebarik26, looked into this and the real workaround is to unload the project/solution and reload after updating the Microsoft.VisualStudio.Azure.Fabric.MSbuild Nuget package. There is an issue in Nuget that we working around https://github.com/NuGet/Home/issues/1850 and we have logic in place to detect and fixup the .sfproj but during project load.
Hi,
I tried all workarounds mentioned here and in other threads but the issue is still there. I already tried 1.6.2, 1.6.3, 1.6.4 and 1.6.5. I can successfully build my sfproj locally and deploy it to Azure. But running dotnet build on VSTS for my solution brings the issue with Microsoft.VisualStudio.Azure.Fabric.Application.props file in every case.
What am I missing? I would appreciate any ideas and suggestions.
@alexwilsh, Any reason why you are using dotnet build? Building the solution with .sfproj will require using MSBuild in the VSTS build definition. Also, you should make sure to use "Use Nuget 4.3.0" and "NuGet restore" tasks prior to the Build solution task
@dbreshears, That is interesting question :) I used dotnet build in my local scripts before we decided to go with VSTS. I have .NET Core projects and that was like the option by default. The most interesting thing - it worked locally and that was something that confused me when we switched to VSTS. But after your question I switched to Visual Studio Task. I also added NuGet tasks before VS Task as you suggested. The build is successful now. Thanks a lot for the tip.
This just happened to me updating to the new 3.0.472. I had to uninstall all the packages and reinstall them.
These are all the updates.
The order for the update is important.
1) Microsoft.Service Fabric updates correctly. 2) Microsoft.ServiceFabric.Data updates correctly
Trying to install the others give this error
Rebooting Visual studio, uninstalling them all and reinstalling in the end works. Please fix this
Same issue in Team City its the way, SF requires MSBuild.
Just to add our issue to this, as I think it's related.
We have a large solution based on the full framework (currently 4.6.1, but in progress of updating to 4.7.2), that we've recently added a service fabric project to.
Our automated build runs on custom build servers based on Cake and in the clean section of the script it is blowing up on the sfproj as it is hitting the ValidateMSBuildFiles. This checks for the existence of
To workaround this and ensure clean builds work in in CI environments, I run nuget restore twice for any solution containing .sfproj
files.
You must use nuget.exe
(not msbuild /t:restore
as the ValidateMSBuildFiles
target causing it to abort right away). nuget.exe
will complain and say it's not going to restore any PackageRefeference
packages, but it will restore packages in package.config
files (which .sfproj
files use) and will get you Microsoft.VisualStudio.Azure.Fabric.MSBuild
downloaded.
The second nuget restore will now work properly and restore any PackageRefeference
packages.
I get the same in VSTS: Error : Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package
If I check my sfproj file, 1.6.7 is referenced. I have no clue as to why the sfproj file in ServiceFabricBackup contains a reference to 1.6.3. I have tried to manually correct the sfproj file in ServiceFabricBackup, but it is overwritted when a new build is started. Has anyone found a solution to this?
Our situation was this:
We were changing .NET Framework Service Fabric service projects over to netcoreapp2.2
and forcing all target platforms to x64
only. Once we added the AnyCPU
configuration back, the package successfully gets restored.
You can also get it to build with x64 only by doing these build steps:
I was directed here from the Visual Studio Developer Community. Seems like I am having the exact same issue. Using the standard build template that comes with Azure Devops. Using a specific NuGet restore (v4.4.1). My SF project is referencing MSBuild package v1.6.7
I can see in the log from Nuget Restore that the package is being pulled. "Completed installation of Microsoft.VisualStudio.Azure.Fabric.MSBuild 1.6.7 Adding package 'Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7' to folder 'D:\a\1\Nuget\External\Packages'"
But the Visual Studio Build task to package the sfproj is failing with this error. "Error : Unable to find the '.......nuget\External\Packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package."
All builds locally just fine, issue is only in Azure DevOps. I've verified that all ServiceFabricBackup folders have been deleted. Building x64 as required.
I have tried adding a NugetRestore for the solution and a separate one pointing to the package.config inside the sfproj, did not make any difference.
Thanks for any help, Will
Just for grins, I created a basic SF project - straight out of the box, no changes of any kind. Verified that it builds/packages/deploys locally. Committed it to Azure Devops. Created a new build definition using the Azure Service Fabric application template, made no changes. Same error. Definitely not something I've misconfigured.
Running into this issue again, just trying to upgrade the nuget packages in my SF projects to the latest version caused the Fabric MSBuild target to update from 1.6.7 to 1.6.9 everywhere and in the packages.json file but the .sfproj itself still had 1.6.7 references all over it, and manually changing to 1.6.9 fixed it.
There needs to be a better way than running into this error, googling this thread, and then manually fixing it, every time.
To workaround this and ensure clean builds work in in CI environments, I run nuget restore twice for any solution containing
.sfproj
files.You must use
nuget.exe
(notmsbuild /t:restore
as theValidateMSBuildFiles
target causing it to abort right away).nuget.exe
will complain and say it's not going to restore anyPackageRefeference
packages, but it will restore packages inpackage.config
files (which.sfproj
files use) and will get youMicrosoft.VisualStudio.Azure.Fabric.MSBuild
downloaded.The second nuget restore will now work properly and restore any
PackageRefeference
packages.
Calling nuget restore twice worked for me. I'm using Jenkins FYI.
You must use
nuget.exe
(notmsbuild /t:restore
If you see an error: "The OutputPath property is not set for project '***.sfproj'" this is why.
On the SF proj file it usually says 'InitialTargets=";ValidateMSBuildFiles">' delete this along with the target at the bottom of the file for completeness for me it looked like the code below.
Calling nuget twice isn't a fix, its a hack.
`
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.7\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
`
The reason I got this error was because the sfproj project by default has both Build and Deploy set in Configuration Manager for the solution. Removing Build makes it possible to use "dotnet restore/build" on solution file.
As far as I know the Build shouldn't really be there and it doesn't have to either. Later on in the pipeline, after successful restore/build with dotnet, I do a nuget restore on the sfproj file and a VSBuild with target Package on sfproj file. There isn't really anything to build in the sfproj.
cjfarrelly that worked a treat. Nice one.
The double restore thing did indeed work but I agree - that is no solution. I'm not sure if we lose anything by not doing this, but I've a green build now so will test further.
This whole thread/issue is a disgrace. Does anyone actually use/test Service Fabric? I'm sick of dealing with these problems such as the sfproj format, and the issue where updating the packages.config doesn't update the sfproj either.
It seems like Microsoft have informally dumped it.
To the repo owner(s), is the proposal from @cjfarrelly above: https://github.com/Azure/service-fabric-issues/issues/840#issuecomment-572615400 the solution to this problem?
We were running into issues when using nuget 5.5.1 and the newer msbuild 16.5.x. Using the proposed changes seems to have fixed our issues. If not are there any steps we can take?
It seems like this was one some boilerplate configuration that was used across the board which is now incompatible with the latest toolset.
@mrohera Removing the "ValidateMSBuildFiles" from InitialTargets is recommended (we have changed out templates to no longer add this). Removing the target altogether is not necessary, but also not harmful (you just won't get as helpful a message in the case of the NuGet not being restored).
@NCarlsonMSFT, thanks for getting back to me :). Are you saying that we keep the ValidateMSBuildFiles
checks as is just not triggered via InitialTargets
? If yes, where should we keep the checks to make sure our stuff is restored and built correctly? The idea here is to not have silent build failures and catch anything early on.
If it helps this is what we have now:
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.ServiceFabric.props))\Microsoft.ServiceFabric.props" />
...
...
<Target Name="ValidateMSBuildFiles">
<Error Condition="!Exists('$(NUGET_PACKAGES)\Microsoft.VisualStudio.Azure.Fabric.MSBuild\$(ServiceFabricMSBuildVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '$(NUGET_PACKAGES)\Microsoft.VisualStudio.Azure.Fabric.MSBuild\$(ServiceFabricMSBuildVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('$(NUGET_PACKAGES)\Microsoft.VisualStudio.Azure.Fabric.MSBuild\$(ServiceFabricMSBuildVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '$(NUGET_PACKAGES)\Microsoft.VisualStudio.Azure.Fabric.MSBuild\$(ServiceFabricMSBuildVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
</Target>
The target should have a BeforeTargets attribute:
<Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
In spite of what this thread indicates, there are conditions in which InitialTargets=";ValidateMSBuildFiles"
seems to be required. Or I just haven't been able to put the right solution together.
While building locally worked fine, my ADO build kept failing. I've got a solution of projects that has a mix of PackageReference and my sfproj's that have packages.config. I tried the various fixes, save for deleting the whole validation logic altogether, and they all failed for one reason or another. For some reason, including the InitialTargets condition causes my first nuget restore to do a packages.config restore and restore to both the global nuget cache and the solution level nuget cache the build tasks depend on via relative reference. Not sure why and giving up trying to figure out a better solution.
Leaving this here in case it saves someone else the headache of not trying because "it shouldn't be required".
I had the same problem with the restored package after I updated from 1.7.2 to 1.7.3.
In run on the devops pipeline with
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
but localy the package wasn't found. So I implemented the following workaround
<PropertyGroup>
<!-- This version number must be the same as in packages.config -->
<ServiceFabricPackageVersion>1.7.3</ServiceFabricPackageVersion>
<ServiceFabricPackageRootFolder>..\packages</ServiceFabricPackageRootFolder>
<ServiceFabricPackageRootFolder Condition="!Exists('$(ServiceFabricPackageRootFolder)')">$(APPDATA)\BuildConfig\packages</ServiceFabricPackageRootFolder>
<!-- Nothing found: back to start. -->
<ServiceFabricPackageRootFolder Condition="!Exists('$(ServiceFabricPackageRootFolder)')">..\packages</ServiceFabricPackageRootFolder>
</PropertyGroup>
<Import Project="$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
And at the end of the sfproj file I changed to:
<Import Project="$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
<Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists('$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '$(ServiceFabricPackageRootFolder)\Microsoft.VisualStudio.Azure.Fabric.MSBuild.$(ServiceFabricPackageVersion)\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
</Target>
Now it's running local and in the pipeline.
the whole thing is not fit for purpose and hasn't been for years. the whole toolchain is questionable, nuget has over 2k issues logged against it. most of the devs have moved elsewhere. they seem to work on the principal, let's buy a phone company, ah, no we're bored now, let's dump it. let's build a voice system and embed in some speakers that seems like a good idea... ah, no we're bored now, let's give 20 bucks and f*** 'em off. let's build a dual screen android phone (but not call it a phone), because we've never failed at that before... you know we're not much cop at android... i wonder....
Inderministic targets and should be available over built-in support for Dotnet build tool extension.
I followed MartinDemberger's steps. And in my yaml I needed to add:
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
solution: $(SlnPath)
restoreDirectory: '$(System.DefaultWorkingDirectory)/packages/'
restoreDirectory refering the the packages folder
On latest Service Fabric SDK / .NET Core SDK / VS2017 community edition, we have 1 package reference Microsoft.VisualStudio.Azure.Fabric.MSBuild for service fabric project. I have checkin the solution and triggered build in VSTS it is failing to restore packages for .sfproj
To expel this issue, i have checkin the packages folder manually as a work around.