How to get import custom tasks more than once without warning message? - msbuild-task

I'm using some custom tasks from MSBuild Extension Pack (MEP). My projects are splitted among many files. In those files I import the MEP tasks using (twice or three times in two/three files). I receive the warning message when doing this like:
... warning MSB4011: "C:\Program
Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks"
cannot be imported again. It was
already imported at
"D:...\Tasker.proj (5,3)". This is
most likely a build authoring error.
This subsequent import will be
ignored.
Does anyone know how to get rid of this warning message? Please help!

The work-around of this question would be: Calling the import with condition to check the existence of a unique property defined in the considering project file. Hope this helps!

That warning has happened to me when I have built my application from VS IDE and by MSBuild tool in parallel. I guess the same might happen when you work with more than one VS window on the same project

Delete the automatically generated file yourproject.nuget.props and the warning will go away.

Related

Nuget package silently adds back deleted files to project directory not only initially, but on every solution open

It's an installed nuget package https://www.nuget.org/packages/AppDynamics.Agent.Windows/ that adds AppDynamicsConfig.json and AppDynamicsAgentLog.config to a project directory on the first install.
If you delete any of those files, it will be automatically and silently restored. I understand that this behaviour is explicitly set in nuget package specs, but several questions:
How this behaviour can be disabled without changes in nuget package itself? The only way that i've found is to add fake file, it works because nuget specs set as 'restore only if file doesn't exist'. But it's just a workaround, it should be a normal way to disable it.
It works silently on a moment of the opening solution and also works almost immediatly if solution is open. How the related nuget/build/whatever task is named and where logs for this restore is presented?
How this behaviour can be disabled without changes in nuget package
itself? The only way that i've found is to add fake file, it works
because nuget specs set as 'restore only if file doesn't exist'. But
it's just a workaround, it should be a normal way to disable it.
The answer is negative. The behavior can't be disabled if you're not willing to change the files in that nuget package. At least for now there's no normal way to disable it.
It works silently on a moment of the opening solution and also works
almost immediatly if solution is open. How the related
nuget/build/whatever task is named and where logs for this restore is
presented?
The related build target is named as CreateAppDynamicsConfigFiles, defined in AppDynamics.Agent.Windows.targets in path: appdynamics.agent.windows\4.5.16\build\netcoreapp2.0.
And there's no logs for this silent restore, cause this target runs before the build. So normal VS output window(display the build log,nuget package log...) can't have any log for it.(Also, the author doesn't define custom way to write logs in that target when creating the package)
Detailed Description to help us understand the negative answers above:
See part of the content:
<Target Name="CreateAppDynamicsConfigFiles" BeforeTargets="BeforeBuild;CompileDesignTime"
Inputs="$(AppDynamicsAgentDistribMicro)\AppDynamicsAgentLog.config;$(AppDynamicsAgentDistribMicro)\AppDynamicsConfig.json"
Outputs="AppDynamicsAgentLog.config;AppDynamicsConfig.json">
This target's BeforeTargets=BeforeBuild;CompileDesignTime, so this target runs before the CompileDesignTime target.
This target is a particular one for VS IDE. It represents the time when we develop in VS code editor.So for the CreateAppDynamicsConfigFiles which runs before it, it will always execute when loading the Solution or when the solution is open(available to develop).
Not the target always run when solution is open(loaded), let's see the task in this target:
<Copy SourceFiles="$(AppDynamicsAgentDistribMicro)\AppDynamicsAgentLog.config" DestinationFolder="." SkipUnchangedFiles="True" Condition="!Exists('AppDynamicsAgentLog.config')" />
So: VS will always run the target when project consuming that package is open=>the Copy task in the target will run if AppDynamicsAgentLog.config doesn't exist in Project folder=>The strange behavior occurs(If the solution is open, more accurate, the project is open, the files will always be restored)
Suggestions:
1.There's no normal way to disable it if you don't want to change the package itself. You may have to contact the author of the package to add the option(a msbuild property) when creating the nuget package.
2.If you're willing to modify the installed package, you can disable the behavior temporarily by modifying the target.(Add condition=false to that target and do some similar actions to other similar targets). And you can also consider removing that package from your project if it's not necessary.
3.Use your workaround(fake file)...
Hope all above resolves your puzzle about this issue :) If I misunderstand anything, feel free to correct me!

MSBuild.ExtensionPack.tasks inheritance of variables from MSBuild main project file

Case:
When I build from MSBuild (with VS Build Tools 2017) I don't get any value for $(ExtensionTasksPath) variable
from main msbuild file, when I build with integrated VS MSBuild value is passed from main file to MSBuild.ExtensionPack.tasks, is that expected behavior and why does it happen? I don't use any properties for the sake of testing that particular case.
Is that expected behavior and why does it happen?
I think it's not we expect.As I test on a VM, the msbuild from VS Build Tools2017 get the same value as what we can get in msbuild from VS IDE.
For the reason of this behavior I have some suggestions to help trouble
shooting:
1.First of all, make sure both two scenarios builds successfully.
2.As you mentioned above, you runs them in separate VMs, make sure the two file under test are the same and entire solution folder.(The package folder under solution directory makes sense)
3.Check in the .xxproj file, check if exists <Import Project="..\packages\MSBuild.Extension.Pack.1.9.1\build\net40\MSBuild.Extension.Pack.targets" ...>
I've found the $(ExtensionTasksPath) property is defined in MSBuild.Extension.Pack.targets file, and this file is imported into .xxproj file by <Import> tag.
Have a look at pics below from my sample project which install MSBuild.Extension.Pack by nuget:
After my project install the extension bu nuget, there is an Import sentence in csproj file, open it we can find:
The value of $(ExtensionTasksPath) in defined here. So i guess you may have sth missing with the targets file or the import sentense or have sth corrupt this property.
In summary:
1.keep the entire solution folder could be the best suggestion.
2.And if it not works, add a script below to your .xxproj file can work:
<PropertyGroup>
<ExtensionTasksPath> Absolute path of your MSBuild.ExtensionPack.dll</ExtensionTasksPath>
</PropertyGroup>
It will overwrite values from tag and no matter where you put the assembly, just add the absolute path can work.
It my answer is helpful, please give me a feedback. And any update please feel free to contact me.

How to disable automatic ES6 import statements in Visual Studio 2017

Reference to a similar question for VS Code
Since one of the more recent updates, VS2017 has been adding automatic imports when autocompleting statements in JS with tab/enter. This has lead to some frustrating incidents where it tries to import some faraway module when using things like setTimeout or document.
In VS Code, as seen in the referenced question, it is possible to turn this off. I have not been able to locate a similar setting in VS2017. Is it possible to disable or configure this behaviour?
Furthermore, it has also started inserting snippets (for example, with class). Is it possible to disable/configure this setting as well?
I am currently using version 15.6.7.
As a workaround, you can create an (empty) tsconfig.json file in the root of your project. This will stop Visual Studio from trying to import NodeJS libraries, which was the cause of my problem.
Note that if you are using MSBuild to build your project (e.g. through TFS), you will also need to add at least one .ts file to your project. This can also be empty. For example, I added an empty empty.ts file to the root of my project.
It's not beautiful, but it works for now.

Introjucer/Visual Studio 2013 object file clashes

I've got two files in my build named State.cpp. When I generate the VS project with the Introjucer and try to compile, both of those files clash to the same object file and I get the warning:
Warning 1 warning MSB8027: Two or more files with the name of
State.cpp will produce outputs to the same location. This can lead to
an incorrect build result. The files involved are
......\audio\State.cpp, ......\sg\State.cpp.
and then various link errors.
I can correct this easily enough within VS by modifying the Object File Name property on the VS project. However, when I regenerate the project with the Introjucer, that setting gets blown away.
Is there a setting I can use in the Inrojucer's config pages to prevent the clashes?
Just to close this one down...
There isn't. Rename the file for now.
We discussed this on the forum. I think Jules is up for making a change to the Introjucer to fix this - but it hasn't been done yet.
http://www.juce.com/forum/topic/msvc-build-consistency
http://www.juce.com/forum/topic/introjucer/visual-studio-2013-object-file-clashes

VS 2010: "Always Create" was specified

I am trying to compile a c++ simulation, that was previously written in VS2008.
It gives error exe not created, because "Always Create" was specified.
I have tried every solution, edited devenv.xml, changed verbosity output. Kindly anyone could give any idea.
Thanks.
This problem will occur when one of the include files listed in the project doesn't actually exist. You may have deleted the file, but forgot to remove it from the project.
The dependency checker then believes the project is not up to date, but the builder finds nothing to build.
A quick check that all project files can open in editor will help you fix this problem.
Well, it could be because a dependency, or the verbosity output level. Here are more options to you to take into account:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/38c08137-3bb0-4143-b97f-72d077646318/visual-c-2010-build-questionissue?forum=vcgeneral

Resources