MSBuild, properties and imported files - msbuild

Is it possible to run an msbuild task that populates a property or Item from an imported file "A" and then use these values in another file which imports file "A"?
EDIT: FileX imports FileA and FileY imports FileA. One of FileA's property is changed in FileX. Can this changed value be accessed in FileY

Sorry its a bit confusing:
Are you saying FileX imports FileA and FileY imports FileA. FileX sets property P in FileX but FileY reads it? If there is no relationship between X & Y then the only way to do it would be use the fact that properties in MSBUILD overlap with evironment vars. So possbly calling
<exec ... setx.exe Propertyname SomeValue.... /> in fileA and the $(Propertyname) in FileB

Related

How to write Fortran modules in UMAT subroutine in ABAQUS?

I have 3 modules (in free form .f90 format) which are being called from inside of UMAT subroutine, such as:
module module_A
use module_C
use module_B
....
end module_A
module module_B
use module_C
....
end module_B
module module_C
....
end module_C
subroutine UMAT(STRESS,...)
....
Here the subroutines from module_A and module_B are being called
...
end subroutine UMAT
Now, my question is what should be the appropriate format of writing these modules with UMAT subroutine? How to merge different module files into a single *.for file (free format)?
If I understand correctly you have multiple source files that you want to compile for your UMAT. Since the built-in Abaqus make utility only takes one file you can use an INCLUDE statement to tell the Fortran compiler to include other source files in the main source file. So let's say you have four files: module_A.for, module_B.for, module_C.for and umat.for. umat.for should contain some INCLUDE statements at the top:
INCLUDE 'module_C.for'
INCLUDE 'module_B.for'
INCLUDE 'module_A.for'
SUBROUTINE UMAT(... umat args ...)
USE module_A
ENDSUBROUTINE UMAT
Make sure all of the *.for files are in the same directory so the compiler can easily find them. When the compiler encounters an INCLUDE it will read the referenced source file and continue compiling as if it's contents were directly in the umat.for source file, and then return to compiling umat.for.

Import header files with open: namespace / module error

I don't understand how to work with F# header files.
I have two test files:
Foo.fs:
module Foo
let add a b = a + b
Program.fs:
open Foo
printfn "%d" (add 8 2)
In the file Program.fs, Visual Studio tells me:
Files located in libraries or applications containing multiple files
must start with a namespace or module declaration.
Only the last source file of an
application can omit such a statement.
However, I did the right thing: start my Foo.fs file with a module declaration. If I declare a namespace or module to Program.fs, the error persists. So I don't have access to the add function.
How do I import this file?

IntelliJ - File watchers: wrong output of macros

I am trying to setup a file watcher for scss files which is working on files with a filename not starting with _.
But if I have a file named _file_name.scss the output of any macros that include the filename will be file.name.scss.
The first _ is removed and following ones are replaced by ..
Even though in the insert macros selection tool I can see that the output when you select a macro is correct.
Like $FilePathRelativeToProjectRoot$ will display mypath/_file_name.scss in the selection tool but then my command from this file watcher will output mypath/file.name.scss.
Am I missing a parameter here ?
Full configuration:
For me, existing file names are not changed when using similar file watcher. But files with names starting the _ are not prettified, the main .scss that includes them is processed instead.
To avoid this, try adding COMPILE_PARTIAL=true variable to your file watcher settings:
Also, make sure that Track only root files is off.
See the comments in https://youtrack.jetbrains.com/issue/WEB-13459

How can I add more sources files to a target after the target has been created in cmake

I use the following example to show my question: suppose now I have created a target using the following commands in CMake:
add_custom_target(MyProject SOURCES a.txt b.txt)
After this target is created, more files are put to the target, and in order to do that I use the following command:
set(moreFiles c.txt d.txt e.txt)
set_target_properties(MyProject PROPERTIES SOURCES ${moreFiles})
However, in VC the added files to the target is only c.txt, other files such as a.txt,b.txt,d.txt and e.txt are not available in the target. Anything I can do for improvement?
For non-trivial manipulations with properties, it's best to forego the shorthand functions like set_target_properties and use the full power of set_property:
set_property(TARGET MyProject APPEND PROPERTY SOURCES ${moreFiles})
If, for some reason, you'd want to keep using set_target_properties for that, you'd have to query the current value first, and quote the entire result:
get_property(currentFiles TARGET MyProject PROPERTY SOURCES)
set_target_properties(MyProject PROPERTIES SOURCES "${currentFiles};${moreFiles}")
The quoting is important, because the shorthand set_*_properties commands expect their arguments to be ... PROPERTIES prop1 value1 prop2 value2, that is, an alternating list of property names and values. Your original command set the property SOURCES to c.txt, and then the property d.txt to the value e.txt.

Skipping MSBuild target

Is there a way to use MSBuild syntax to skip a specific target? I have a file consisting of a lot of properties (lines containing /property:X=Y) that I want to pass on to a recursively called instance of MSBuild, but this file also contains a /target:X line, that I do not want to have any effect. I don't have the option to modify the file.
I suppose you are able to edit .proj file. You can manage MSBuild targets executing by the Condition. Your target, which you want to exclude, could contain something like this:
<Target
Name="SomeTarget"
Condition="'$(SomeProperty)'=='true'"
DependsOnTargets="SomeAnotherTarget"/>
SomeProperty can be passed in the calling:
MSBuild.exe build.proj /p:SomeProperty=false
Regards