Is it just me, or Visual Studio 2012 with most recent update, package the current environment release upon publish, rather than the release specified in the publish settings?
UPDATE: To force it to build in release mode I have to update the build definition as per this SO question:
How do I force my TFS 2010 Build to build all projects in the solution to be built in Debug or Release Mode?
Not sure why I suddenly have to enforce this flag though??
It's not just you - I've been seeing the same thing for a week or so now and couldn't figure it out. When I remoted into my Azure vm I saw the the web.config it had published was just the debug one - yikes! Maybe it's not running the web.config transforms or something?
Related
Oh, the most annoying thing ever :( So I spent some time trying to get my old application to compile using c# 7 and managed it, now that is finally working I was ready to setup devops.
I created my pipeline as usual, but the first issue was when I pushed a build, it moaned about not supporting .net 4.7.2. Awesome.
So I downgraded the project to 4.6.2 and then ran my pipeline again and now I get this:
Invalid token '=>' in class, struct, or interface member declaration
I have checked the nuget restore in devops and it is using .net compilers 2.10.0.
I am at a loss. Does anyone know how I can fix this?
Your Agent pool may need to be Hosted VS2017.
As #NicoD mentioned, we also are building c# 7 projects with no issues by targeting this host.
For other users who have custom/hosted agents, you have to install this in server where agent runs:
Be sure you have correct Build Tools for Visual Studio installed: How can I install the VS2017 version of msbuild on a build server without installing the IDE?
And don't forget install this option too: MS-Build 2017 "Microsoft.WebApplication.targets " is missing
I am attempting to move a solution from TFS 2012 to TFS 2018 SP2RC2 but I can't get the unit tests to run correctly. All projects have been re-targeted to 4.7.1 and are built as x86 platform. We have a testsettings file that supplies nothing but deployment items. I am using the new VSTest Platform Installer task (as directed by MS) and the VS Test Task. At the start of the test run I get the following message:
Test run will use DLL(s) built for framework .NETFramework,Version=v4.5 and platform X86. Following DLL(s) do not match framework/platform settings.
So all of the test are skipped as they target 4.7.1. Where is this 4.5 setting coming from? I cannot find it specified anywhere and can't figure out how to change it.
There is a /Framework: parameter that you can specify to VSTest.
In your case, you should specify /Framework:.NETFramework,Version=v4.7.1
See more at https://msdn.microsoft.com/en-us/library/jj155796.aspx?f=255&mspperror=-2147217396
To add this parameter in a Azure DepOps yaml pipeline, use the otherConsoleOptions argument
- task: VSTest#2
otherConsoleOptions: '/Framework:.NETFramework,Version=v4.7.1'
The fix I found for this in Visual Studio is way easier than I thought:
Exit all instances of VS
Open your project folder in Windows Explorer, find the .vs folder, delete it
Restart VS, the folder rebuilds itself, tests work again.
Apparently there are some settings that the NUnit plugin stashes in this folder and they are in binary so you can't edit them. This happened to me after I updated to NUnit3TestAdapter version 3.17.
I had trouble running a test project developed on another machine where no tests where able to be run using the MSTest test runner. In addition to message in your question I also got the messages:
Make sure that test discoverer & executors are registered and platform
& framework version settings are appropriate and try again.
Discover test finished: 0 found
In my case I resolved it by unloading and updating the .csproj file adding the following import directly under the root Project tag.
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" />
Hope this answer will help save you some time.
I got this error using Visual Studio 2019 with NUnit 3.12.0:
Test run will use DLL(s) built for framework
.NETFramework,Version=v4.5 and platform X86. Following DLL(s) do not
match framework/platform settings.
Project.UnitTests.dll is built for Framework 4.5.2
and Platform AnyCPU.
Installed NUnit3TestAdapter 3.13.0 and then everything started working. Did not need to modify Framework version or CPU settings.
Had the exact same issue as Bill, working on legacy code in VS2019, nothing else had worked. I simply changed the Run Settings to use the Auto Detect.
In the menu go to Test -> Configure Run Settings -> Auto Detect runsettings File
For me skipping tests in local VS2022 run was related to testsettings file. I deleted .vs folder of my project then selected
Test ->Configure Run Settings -> Select Autodetect run settings file
After that I can debug unit tests
TLDR: If you use *.runsettings file for your test projects, try removing TargetFrameworkVersion node
I had similar problem but with .Net Core
Test run will use DLL(s) built for framework
.NETFramework,Version=v4.0 and platform X64. Following DLL(s) do not
match framework/platform settings. MyProject.Tests.dll is
built for Framework .NETCoreApp,Version=v3.1 and Platform AnyCPU.
Turns out there was another problem. For my other .NET Framework test projects I had defined *.runsettings file
And in this file I had
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="ConnectionString" value="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True" />
</TestRunParameters>
<RunConfiguration>
<!-- Framework35 | [Framework40] | Framework45 | FrameworkCore10-->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
</RunSettings>
Supported values for TargerFrameworkVersions based on https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019
are:
FrameworkCore10 for .NET Core sources, FrameworkUap10 for UWP-based
sources, Framework45 for .NET Framework 4.5 and higher, Framework40
for .NET Framework 4.0, and Framework35 for .NET Framework 3.5.
But for Core 3.1, FrameworkCore10 doesnt work!
So I removed node TargetFrameworkVersion completely
I had the same problem in VS 2019 on a legacy project.
Restarting Visual Studio did not help, nor did build as Release then rebuild as Debug, nor did deleting the .vs folder. I did those things and still was unable to run tests, getting a message like the OP's during test detection each time. I mention these here for completeness.
I deleted the LocalTestRun.testrunconfig file and the *.vsmdi file from Solution Explorer, cleaned and rebuilt the solution, and the unit tests worked again.
I was running into the same issue with the Visual Studio Test Task version 2 in an Azure Devops 2019 pipeline after a .csproj test project was upgraded from .NetFramework 4.6.1 to .NetCore 3.1.
The fix for us was to be more specific when specifying the test files. The default of **\*test*.dll was finding several other assemblies with "test" in their names that didn't exist before the upgrade. Using an explicit **\<MyTestAssemblyName>.dll fixed the issue.
My VSTS Repository contains 50+ Visual Studio projects of Azure Web Apps and I was requested to get an automated build and release process in place for one of them. I went thru and selected a Visual Studio template and on the build solution I selected only the one project I wanted to do a build and release on but when I queue the build to run it starts doing a get latest on every project in the repository. This is unacceptable because it would take hours to get latest on all the projects just to compile and publish one website. This makes no sense to me. Is there a way to limit what the build does a get latest on?
Depends on the repository type you're using. In case you're using TFVC, you can go to the Repositories tab and configure your workspace mappings to match exactly what you need for your project.
If you're using Git, then you're out of luck, the way git repositories are synced, the whole repository is always fetched when a build is initiated.
If you're using your own build agent, you can configure it to retain the sources directory, in which case only the differences are synced when a build runs.
We currently use TFS to deploy builds to our servers in different environments such as QA, PreProd and Prod. In the current method, the build agent gets all latest from TFS, builds and publishes to whichever environment specified.
I know that you can actually just publish just to a drop folder where it creates PublishedWebsites folder, but how can you publish to servers from drop folder mentioning specific build? For example, there may be build #7, which our QA team has certified. We want to make sure that that is the build that is going to production and not latest content which might have some check ins from other team members.
Any help would be appreciated. I referred this link, but it is mentioning about overriding OutputRoot directory in publish.proj file, which is not created in the solution that we created using Visual Studio 2012.
http://www.asp.net/web-forms/tutorials/deployment/configuring-team-foundation-server-for-web-deployment/deploying-a-specific-build
You have multiple way of solving the needs.
The best option is to use LabManagement; it will take care of computing the correct Drop folder. See Using a Lab Environment for Your Application Lifecycle for details. The idea is to use the build-deploy-test workflow to deploy and run tests on a group of machines running Test Agent.
You can setup a more sophisticated process using Release Management, a new feature of TFS 2013 that you can add to 2012 as well. It offers to design your promotion process and control who authorizes deployments.
You should neither use Build or Lab Management to do deployments. Both are poor solutions for this as this is not what they were designed for.
Microsoft added a dedicated release management tool with visual studio 2013. I have configured and used it with both 2012 & 2013.
http://nakedalm.com/building-release-pipeline-release-management-visual-studio-2013/
This will be much easier than either of the other tools.
I have setup my .NET project in TFS Build. It builds fine locally, but I am getting this build error on the server:
The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
I have no idea what it is, even googling didn't help much. My solution has some database projects. What is the issue here and how I can fix it?
You need to install the SQL Server Data Tools on all build agents. When installing a TFS Build server, people often create agents to be on that or other machines.
You can download them from the MS SQL Server Data Tools Blog or Microsoft SQL Server Data Tools, and you choose the one that corresponds to the builds that you doing (Visual Studio 2010 or Visual Studio 2012).
Note: In some cases, the error mentions the path:
c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets
In such cases, install SQL Server Data Tools from SQL installation, not the link above.
I have solved a similar issue by adding a new Solution Configuration that does not build the SQLPROJ. I then configured CI-CD (Azure DevOps Pipelines) to build that configuration.
In a subsequent step of the Build, I exclusively build and pack the SQLPROJ. By thisI avoid having two Solutions - one of which will only have on project; the SQL Project.
For quite a while already we use ReadyRoll.MSBuild NuGet package. Event that ReadyRoll is not ReadyRoll anymore, it is still being regularly updated and keeps working with most recent SCA addins. It contains same build extensions, and works flawlessly on our build agents without need to install anything. Biggest problem is absence of nuget support in .sqlproj files, which makes adding/updating packages bit tricky: https://documentation.red-gate.com/rr1/installing/build-components
SQL Change Automation documentation doesn't contain this section, so it's hard to say for sure how long will it stay the way it is.
For the sake of completeness, properties to add to your .sqlproj as of today:
<ReadyRollNuGetBaseFolder>$(MSBuildThisFileDirectory)..\packages</ReadyRollNuGetBaseFolder>
<ReadyRollNuGetIsRestored Condition="$([System.IO.Directory]::GetDirectories($(ReadyRollNuGetBaseFolder), 'ReadyRoll.MSBuild.*').Length) != 0">True</ReadyRollNuGetIsRestored>
<SqlChangeAutomationTargetsPath Condition="$(ReadyRollNuGetIsRestored) == 'True'">$([System.IO.Directory]::GetDirectories($(ReadyRollNuGetBaseFolder), 'ReadyRoll.MSBuild.*')[0])\tools\ReadyRoll.Data.Schema.SSDT.targets</SqlChangeAutomationTargetsPath>
If this problem occurs on Azure DevOps pipeline build agent, then please use MSBuild#1 instead of DotNetCoreCLI#2 in the pipeline YML task. It worked for me.
- task: MSBuild#1
displayName: 'Build SQL solution'
inputs:
solution: <SQL DB Solution>.sln
msbuildArchitecture: x64
msbuildArguments: '/property:DSP="Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider"'
configuration: 'release'