Why Visual Studio is not copying static files before running tests? - visual-studio-2017

We are currently facing an issue in Visual Studio (v15.7.2): when we are running the tests of our .NET Core project, if we only change the content of a static file (.sql, appsetting.json, .txt, etc), Visual Studio does not see the changes in the files, it uses the old version of it and the tests are not running correctly.
If this the normal behavior, how is it possible to change that and force Visual Studio to rebuild or at least to re-copy the static files and take the changes into account?
Of course, if we change the code, the project is automatically rebuilt and the new files are copied. This issue happens a lot because we are using SQL files to setup the database state before running our integration test.
Minimal project code to reproduce it is available here: https://github.com/Gerfaut/dotnet-core-test-static-files
Steps to follow:
Open the project in Visual Studio 2017 and run the test → The project is built and the test is green ;
Change the content of the file Project/wwwroot/static-file.txt to "This is NOT a static content" ;
Run the test → The test is still green although the content of the file has changed and should fail the test.
Thanks a lot for your help,
Gerfaut

Related

Text is an invalid XmlNodeType when running Visual Studio tests

I have been creating test automation using Visual Studio Test. My Code is stored on Visual Studio Online and it uses GitHub to store the source code.
The problem is as of this morning, I started seeing the error "'Text' is an invalid XmlNodeType' when I try to run my tests from Visual Studio' Test Explorer.
I have been adding new test methods to the source and updating the test.runsettings file with additional parameters. The test.runsettings file is getting large, as I have about 152 tests.
I can't post the runsettings file, as it contains server names ad infinitum.
And the server tests code is standardized MS unit tests.
Has anyone seen this issue pop up?
I don't have an answer as to why the project can't be run in Visual Studio 2017, however I found a workaround. I'm using VSTest.Console.exe on the command line to test my automation.
vstest.console.exe myTests.dll /Settings:test.runsettings /Tests:TestMethod1 /Diag:Info.txt

How do I alter the full path of visual studio project so I can use it on multiple computers?

So for a class we have a couple of programs where we are using opengl. To make setup easier we started by cloning glitter https://github.com/Polytonic/Glitter. I then compliled it according to the instructions for visual studio 2017 and added my code to the project I am working on. I did this on my desktop computer but saved the files in onedrive. When I open the same project on my laptop and try to build the project I get the error "the source directory D:/OneDrive/fall_2017/Glitter does not appear to contain CMakeLists.txt" and several other similar errors. On my laptop the directory to the files is C:/Users/Me/OneDrive/fall_2017/Glitter. The visual studio program lists the full path as D:/OneDrive/fall_2017/Glitter which is the path of the folder on my desktop.
Is there a way for me to change the filepath or is the issue with my cmake file? Do I have to rebuild it for every computer I use it on? I don't know a whole lot about visual studio so I don't know what I need to change to get this to work.
Turns out I have to rebuild on every computer. Thanks to those who left comments.

Anyway to stop 2008 and 2012 Visual Studio builds mixing through TeamCity?

I have a legacy system, with C++ dlls, libs, and exes.
We build against either 2008 or 2012.
Obviously if a 2008 dll gets accidentally added to a 2012 build via TeamCity. That will be bad. Crashy. And vice versa.
So does anyone know of a way to get TeamCity to stop that being able to happen. I feel it must be possible as TeamCity runs the builds and as such 'knows' how each artifact was created. Surely there is some way to create a rule or such like that says 'Only 2008 artifacts for this build, otherwise error'?
Can I setup TeamCity to stop accidental 2008 and 2012 build mixes happening? (without using magic).
Ta!
Example:
My2008TeamCity build (Product built using 2008)
Requires artifacts a2008, b2008, c2008
My2012TeamCity build (Product built using 2012)
Requires artifacts a2012, b2012, c2012
The artifacts are DLL's and loaded at run time only.
Recently we ran the My2008TeamCity build.
A few of the artifacts had mistakenly been setup, through TeamCity to come from 2012 builds.
i.e. a2012 was added to a 2008 build as an artifact.
As the DLL is only loaded run at runtime, we didn't notice the problem until the code was manually run, and that part of the code hit.
Now imagine a huge system, with loads of artifacts, many developers working on subprojects constantly... and something that can guard against this happening suddenly feels required.
Ideally I would like TeamCity to say 'No this artifact was build against 2012, and you are running a 2008 build' and fail the build. So we can fix it.
X
I not clearly sure, are you using all of this in one solution? You can use separate folders of VCS(Build Configuration Settings\Version Control Settings\Edit checkout rules) and for configuration "2012" take only this folder from VCS.

Visual Studio Project always out of date, "up to date is missing #ECHO", why is Visual Studio looking for this input?

Background:
My team wants Visual Studio for development on an existing codebase, for its various tools, and that's what most developers are used to using. However, the existing build system (an internal flavor of Jam) is very entrenched, and for a variety of factors cannot be changed.
The idea:
Create a project for each component. I did this using a description generated by Jam of what files go into each library, and making that into a QT project file. I call qmake on this to generate Visual Studio projects with "qmake -tp vc".
Disable Visual Studio's build. I did this by changing the Type of each source file to "does not participate in build" (by changing each to )
Add a pre-build event that calls the Jam build.
Problem:
Now, when I try to build from Visual Studio, it works, in that it calls Jam.
However, I would expect Visual Studio to think the project is always up-to-date, considering it is not actually tracking any source files for compile. But it is always out-of-date, and must call the pre-build command before debugging (which attaches the debugger to the executable, and works just fine).
I used DebugView to see what was going on, and for many of my projects, I get the following in the log
[12900] Project '<my project's name>' is not up to date because 1 build inputs were missing.
[12900] devenv.exe Information: 0 :
[12900] up to date is missing: '<my project's location>\#ECHO'
I've searched high and low, but cannot find any reference to #echo as a file input to anything anywhere. Does anybody know, and/or is there a way to track down why it is looking for this?

use msbuild to compile a vcxproj created by vs2010 on a computer without vs

I have created a large Visual C++ 10.0 project which builds nicely within the visual studio ide as well as within the "special" Visual Studio Command Prompt using msbuild with a vcxproj file.
However this project needs to be compiled by computers that do not have the vs ide, but only have the msbuild tool and the vc++ 10.0 runtime files.
The problem is that the vcxproj (created by the vs ide) file contains references to files such as Microsoft.Cpp.Default.props and Microsoft.Cpp.targets which clearly won't be available in a computer without visual studio.
Since all the compile and link command line options are available and fixed (no changes will be necessary), how is it possible to create a new vcxproj file to implement the compiling and linking of the project using these options?
I was finally able to make some tests on a "clean" computer. These are the results:
First, I installed .NET Framework 4.0 from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17718. Along with it, MSBuild 4.0 was also installed automatically. When I tried to compile I got the following error:
error MSB4019: The imported project "H:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
which means that extra files are needed to compile the vcxproj and these files were missing. Note that simple project files written by hand (and not by the VS IDE) are expected to compile without problems since they contain no references to theses files (I did not test it for certain).
Next, I installed Windows SDK 7.1 from http://www.microsoft.com/download/en/details.aspx?id=8442. The error about missing files disappeared, but I got a new one. This new error (along with the way I overcomed it) is described in http://www.damirscorner.com/CommentView,guid,9121bd6b-876c-4051-8487-de1b95a7e919.aspx.
Doing the above successfully allowed me build my vcxproj file on a computer without vs2010.
I think that the files that you mention are not part of Visual Studio. They are part of MSbuild.